Javascript Regular Expression for a specific numeric pattern [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 6 years ago.
Improve this question
I'm actually looking for a javascript regex for a numeric pattern. Regex should accept any numeric input of below formats but not 0.0.0
Condition:
each segment in the pattern ranges between 0-10
Valid2.9.60.6.1010.10.100.0.1
Invalid0.0.0
Any help would be appreciated..!! Thank you...!!

Just use a negative lookahead:
/^(?!0\.0\.0$)(?:\d|10)\.(?:\d|10)\.(?:\d|10)$/

Related

Return five characters before and after the match in a regex [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 have a simple Regex to match 'der' - /der/g
I need the context around the match. Is there any way to build the regex that way? Thank you in advance.
If you want to match the context plus the search string, simply add the optional range before and after the searched string: .{0,5}der.{0,5}
If you want to get the context only, you have to fetch it separately: (.{0,5})der(.{0,5})

how to include both digits with hyphens in javascript pattern [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
how to include both digits and hyphens in javascript pattern. Like in phone number where user can add both digits and hyphens. No matter where is the hyphen.
The regular expression to make this is so simple. You can make something like this:
([0-9\-]+)
That means all numbers and hypen no matter where is. You can test it here:
https://regex101.com/r/eX3yA7/1

how to make a regex to accept ONLY alphabet and space [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 8 years ago.
Improve this question
i am using this regex but it still doesn't accept a 'whitespace' input. though it restricts any 'special character'..
.replace(/[0-9]|\W|^\s/,'')
Any help is much appreciated, thanks
You're looking for /[a-zA-Z\s]/. The \s covers spaces (tabs, newlines, etc.). If you literally just want a space " " then change it to /[a-zA-Z ]/.

Email regular expression Javascript [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 9 years ago.
Improve this question
I have a email regex . But i want to allow only 1 to 20 characters before the # symbol in the regex.
([\w-\"]+(?:\.[\w-\"]+))#((?:[\w-]+\.)*\w[\w-]{0,255})\.([a-z]{2,6}(?:\.[a-z]{2})?)
Any help would be appreciated.
You're better off checking outside of the regex, but there happens to be a way in this specific case:
(?=[^#]{1,20}#)([\w-\"]+(?:\.[\w-\"]+))#...

Regular expression needed [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 8 years ago.
Improve this question
I want the regular expression to extract the &[1], &[2},&[3],&[4] values from the following string, with comma delimited.
var str = "Sum({[Account].&[1]+[Account].&[2]+[Account].&[3]+[Account].&[4]})";
Thanks for your help
(&\[\d+\]) Seperates them in to groups, you have to delimit them with commas yourself but that's not a big problem.. :P
Btw.: This is a great test for regex testing purposes http://rubular.com/r/0kLKf1gTaD

Categories

Resources