Reputation: 1207
I want to check the string if it obeys these rules:
My regular expression:
/\d{2}\s.[A-Z]{1,3}\s.\d{2,4}/
It works with most strings but it doesn't with some like these:
Upvotes: 0
Views: 54
Reputation: 59273
Use this one:
/^\d{2}\s[A-Z]{1,3}\s\d{2,4}$/
You were missing the anchors (^
and $
). Your original one would match, say, 134 HY 723
, by matching 34 HY 723
.
I also removed two random .
s. (I have no idea why they were there)
Upvotes: 6