I am using this ^[S-s][0-9]{4}$ to validate my string, but not working properly. my string has to be in the form of the Letter S (upper-case or lower-case) followed by 4 digits, e.g. S1234. Looks like it works for Letters above S, meaning if I enter w1234 it validates correct, but if I enter a letter below s, like a1234 it doesn’t validate. Thanks.
I am using this ^[S-s][0-9]{4}$ to validate my string, but not working properly. my
Share
You need to get rid of the dash:
dashes within
[...]denote character ranges. ThusS-sin regex would mean “every character in Unicode character table between S and s” and as those two are not adjacent, you end up with a bunch of matched chars.