I want to apply a regex to a different strings that I have
all of them start with 3 CAP letters (XXX) and 6 number digits YYYYYY: XXXYYYYYY example: SBV087353
I want to match only the items that match that format of 3 CAP letters and 6 digit numbers.
Testing with an online tool I managed to create this regex: [A-Z]*[0-9]{1,6}
But if I type more numbers after the 6 digits or I type letters at the beginning it keeps matching it anyway.. why?
>Solution :
It’s because you are searching anywhere in string. Include ^ (start) and $ (end) markings.
Also specify exact length of letters and numbers, otherwise you will allow e.g. A1 (or with [A-Z]* even 9)
/^[A-Z]{3}\d{6}$/