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.
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!