Removing specific inputs in any text [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm a complete newbie to programming and I wanna develop a one page-website that removes both numbers and this symbol ==> : from any given sentence.
Let's say you have the following:
(Hey Mr. 11, I'm 18, and I can't wait to turn 20, to own a :)
As you click generate you'd get the following results:
(Hey Mr., I'm, and I can't wait to turn, to own a)
How would you do that?

Here's a dead simple implementation in HTML/JavaScript that uses a regex replacement, to get you started.
document.getElementById('input').onkeyup = function() {
document.getElementById('output').textContent =
this.value.replace(/[0-9:]/g, '');
};
Remove numbers (0-9) and colons (:) from input.
<br>Input: <input type="text" id="input" />
<br>Output: <span id="output"></span>

Related

How to remove specific characters in a string that changes based on request? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 months ago.
Improve this question
I have a string that looks like "{`index`:`20`,`value`:`RA`}<1", and I want it to become "`RA`<1". I don't think the replace function is sufficient as the index and value changes based on what I enter. Is there a way to do that?
assuming the required string is everything after the last :, except for the }, the original string can be sliced and edited as follows:
const string = "{`index`:`20`,`value`:`RA`}<1";
let newString = string.slice(string.lastIndexOf(":")+1).split("}").join("");
console.log(newString);
This will always append everything after the final } to everthing before it but after the last :, regardless of the earlier content.

How to separate a string into a sentence without a proper patern [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
The community is reviewing whether to reopen this question as of 2 years ago.
Improve this question
I have a data that looks like this
Huawei Y7P Art-L28 (4/64gb) (AAAAAAAAAAAAAA) EXP:02/19/2020
Huawei Y9 prime 2019 (BBBBBBBBBBBBBBB) EXP:07/17/2019
Oppo A31 4gb/128gb (CCCCCCCCCCCCCCC)
Vivo Y15 5000mah 4GB/64GB (1901) (DDDDDDDDDDDDDDD) EXP:06/14/2019
And the I want to get this data
AAAAAAAAAAAAAA
BBBBBBBBBBBBBBB
CCCCCCCCCCCCCCC
DDDDDDDDDDDDDDD
Basically what I want to happen is to extract the data from the set of word but my problem here is that its very unpredictable. It has no pattern at all so its hard to separate the string.
Assuming that you need a substring in last parenthesis:
SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(column, '(', -1), ')', 1)
FROM source_table

Auto create links in text following a pattern [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I need to to search through the document text and where it finds a pattern of 0000/0, 0000/00 or 0000/000 (where 0 can be any number) it automatically wraps that text in
0000/00
What I found for auto linkers are only when text is a URL, so it doesn't really help with what I need.
A simple regex pattern would do the trick.
text.replace(/(0000\/[0-9]{1,3})/gm, `$1`);
This will look for 0000/ followed by numbers between 0 and 9, 1 to 3 times.
simple regexp approach
document.body.innerHTML = document.body.innerHTML.replace(/(\d{4}\/\d{1,3})/g,
'$1')
Some text 0000/0 and this 1234/56 and that 7777/666

Finding a faster way of checking characters in js [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm trying to make something that gives an output based on your input. I would like it to take every letter and produce something with the next letter in the alphabet. So if I entered "Hello" it would produce "Ifmmp". The only way I can think to do this is with a series of ifs and else ifs, but I would like to know if there is a faster way.
You can use the String.fromCharCode feature. For example:
let myChar = 'c';
let nextChar = String.fromCharCode(myChar.charCodeAt(0)+1);
console.log(nextChar) // 'd'
In your case, you would replace 'c' with your character variable.

Regular express to match `command--o1--o2--o3` [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have a string like command--o1--o2--o3 ( command,o1,o2,o3 are arbitrary words)
And I want get [o1, o2, o3] though a Regular Expression(Not a array operation or other ways. JUST only use Regular Expression).
Is there any idea to accomplish this !?
If you're using JavaScript, and assuming you want all strings after a --, you may do
var things = str.split(/--/).slice(1)
If you just want to get the 2 characters words following --, then you may use
var things = str.match(/--\w\w/g).map(function(s){ return s.slice(2) })

Categories

Resources