Regex javascript - match either or
Using javascript and .match() can I simplify this regex? I want to match
against a alphanumeric code of 5x5 or 3x5 blocks that is seperated by
hyphens.
For example I want to match:
123EF-12B45-123H5-A2CGE-A2345
or
54321-ABCDE-F2345
So far I tried (\w{5}-){4}\w{5} to match the first example and
(\w{5}-){2}\w{5} to match the second. Is there a way to match either or? I
tried combining the with | but it only matched the 3 pairs.
Or is it better to run regex .match() twice for each pattern?
No comments:
Post a Comment