regular expression
-
Hi can u help me reach a regular expression which will 1: allow 7 numeric digits or 2: 9 alphanumeric or 9 numeric i tried ([0-9]{7}|[a-zA-Z0-9]{9}|[0-9]{9}) but it doesn't allow 9 numerics. thanks
-
Hi can u help me reach a regular expression which will 1: allow 7 numeric digits or 2: 9 alphanumeric or 9 numeric i tried ([0-9]{7}|[a-zA-Z0-9]{9}|[0-9]{9}) but it doesn't allow 9 numerics. thanks
As you already capture the conditions for a numeric only match in the alphanumeric match, you can drop the 9 numbers test and rely on the 9 alpha-numeric test. The key to your solution is to test for the longer character match before you test the shorter match, so your query becomes:
[a-zA-Z0-9]{9}|[0-9]{7}
I'm not a stalker, I just know things. Oh by the way, you're out of milk.
Forgive your enemies - it messes with their heads