I'm trying to use regular expressions to validate a string before converting it to a number. The string must be all numeric (obviously) and exactly 8 digits long. I have tried all of the follow regular expressions:
"[0-9]{8}"
"\d{8}"
"[0-9]{8}$"
"[0-9]{8,8}"
The problem I am having is that the expression returns a Match.Success as long as the string is at least 8 digits long. If it is 9 ot returns OK, and I want it to return false.
Any Ideas????
Thanks Ash..
Loading
Scott LyslePosted Nov 2, 2006, 8:06 AM
Ashley JacksonPosted Nov 2, 2006, 5:01 AM
Scott LyslePosted Nov 1, 2006, 4:08 PM
I tested this on eight digits and it seemed to work OK.
^\d{8}$