This question already has answers here:
Negative lookbehind equivalent in JavaScript
(11 answers)
Closed 7 years ago.
I've seen a few answers that deal with this question but was unable to get them to work.
What is a regex that would match "LOGGED_IN" but not match "NOT_LOGGED_IN"?
^LOGGED_IN$ is first to come to mind
Related
This question already has answers here:
Regex match entire words only
(7 answers)
Closed 3 years ago.
Im using validates_format_of method to check a input text
Javascript cant read this regex. How or where I can change this regex to be as original:
(?<=^|,|\b)[1-7](?=$|,|\b)
Thanks
UPDATE:
the input text must be one o more digits separated by comma, ex: 1|1,2|1,2,3
As #wiktor said you should use
\b[1-7]\b
As \b only asserts positions, you don't need to worry about matching more than [1-7].
#Code Maniac correctly stated that look behind is not supported in Mozilla and many others, so about it. see
This question already has answers here:
How do I split a string with multiple separators in JavaScript?
(25 answers)
Closed 3 years ago.
I have a string "str1+str2-str3*str4".
I want to split it so I get an array
['str1','+','str2','-','str3','*','str4'].
Could someone help provide a solution?
If JS split lets capture groups become elements, then this should work
/([-+*\/])/
if not, I suggest using a regular find all type thing
using this
/([-+*\/]|[^-+*\/]+)/
otherwise, I'll just delete this.
This question already has answers here:
Using explicitly numbered repetition instead of question mark, star and plus
(4 answers)
Reference - What does this regex mean?
(1 answer)
Closed 4 years ago.
Is there any difference between the regular expressions:-
/^[1-9][0-9]+$/
and
/^[1-9]{1}[0-9]+$/
They both seem to give the same result. Which convention is better,because in many examples I can see the use of {1}, but feel it is quite useless, am I right?
This question already has answers here:
Match exact string
(3 answers)
Closed 5 years ago.
The community reviewed whether to reopen this question 2 months ago and left it closed:
Needs details or clarity Add details and clarify the problem by editing this post.
I have this regex to validate Swift BIC:
^[A-Z]{6}[A-Z0-9]{2}([A-Z0-9]{3})?
But this string is correct:
AABSDE31X-X
How would be the regex to match the entire optional part ([A-Z0-9]{3})? if present?
Thanks in advance.
Seems like you just have to append you regex with $ to terminate it :
^[A-Z]{6}[A-Z0-9]{2}([A-Z0-9]{3})?$
A great tool to check your regex here :
https://regex101.com/
Hope this helps!
This question already has answers here:
How to validate phone numbers using regex
(43 answers)
Closed 5 years ago.
My input box must accept the following combination
(123) 123-4567 or 123-123-1234
Can anyone help me out to make regular expression?
Seems trivial :
/^(\(\d{3}\) |\d{3}-)\d{3}-\d{4}$/
demo on regex101