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 years ago.
Improve this question
I want to split strings by commas and dots using javascript. For example, a string of "10,256,326.26" would turn into ["10", "256", "326", "26"] after getting split.
Which regex can I use for this?
You can use a character class containing all characters on which you want to split
var s = "10.269,69";
document.write(s.split(/[,.]/))
You can use split() with a regex:
console.log(str.split(/,|\./));
Related
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 2 years ago.
Improve this question
for example
I would like to match three null in
Sat:null-5:00pm
Sun:null-null
but not a null in snullagain.
How to write such a regex in javascript?
I believe what you want is: \bnull\b
That translates to "word boundary, followed by the word null, followed by a word boundary"
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 5 years ago.
Improve this question
If I have a string in this format:
RED-MPWMC-40486655646-024
How can I extract MPWMC from this string with javascript?
No need of regex here. Just split it using - and access the array element with index=1.
var str = "RED-MPWMC-40486655646-024";
console.log(str.split("-")[1]);
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 5 years ago.
Improve this question
I tried this : [fl]ady?[ing] ?[rb]ug!?
I know [fl]ad[y]?(ing)? ?[br]ug!? is an answer
Can this be solved using character sets only? Must match both.
ladybug
fading rug!
I believe this should work for you
[fl]ad(y|ing)\s?[br]ug?
Check out http://www.regexpal.com/
Using character sets only? So, it doesn't matter what other letter combinations it matches as well? Mmm. Then
[fl]ad[giny]+[\sbrug!]+
would do. See: https://regex101.com/r/FJWJyM/1
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 6 years ago.
Improve this question
Special characters in javascript
Trying to enclose the string containing special characters with in single quotes
i.e gg's in single quotes like 'gg's' or gg's
How to do this? getting error when trying to use above.
just escape the single quote with a backslash
var foo = 'gg\'s';
You can alternate quotation types:
"gg's"
Or you can escape the single quote:
'gg\'s'
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 8 years ago.
Improve this question
My regex pattern for alphanumeric word is as given below :
/([A-Za-z0-9])*$/
Is "testuser" a valid input string for the above pattern?
Use character class.
So use: /^[A-Za-z0-9]+$/
And yes, testuser is a valid input for the above regex.