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!
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
So i want to make a regular expression to validate times between 12:00 and 22:00 but i cant get my head around making expressions and cant find any examples online that i can just swap out examples of. Can anybody help me?
You can use the following regular expression:
^((1[2-9]|2[0-1]):[0-5][0-9]|22:00)$
This is how it works:
^ and $ match start and end of string, and they are there to prevent matching also 112:009 for example (which contains 12:00).
[2-9] matches numbers between 2 and 9, and (a|b) would match either a or b.
Debuggex Demo
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:
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
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
This question already has answers here:
Remove unnecessary close tags using regex
(2 answers)
Closed 8 years ago.
I tried to find the first open tag using regex, but for some reason, it finds the last one.
Example: http://regex101.com/r/pY4bI0
The green part should end at the second line. What do I wrong? How should I fix it?
how about just this?
(\<\w.*?\>)
http://regex101.com/r/eM4fK3