I have to get input from a user in a text box, but I have to validate it
1 It should not take more than 7 digits before decimals.
2. After the decimation it should not take more than 3 digits
I actually found 2 parts, but The first part is still a problem, my regular expression is:
/ ^ ([0-9] {0}} + (\ [0- 9] {1,3}) $ $
Tell me where is wrong Is
suggest a legitimate regulatory expression
You do not need Plus , And I'll use \ d
instead of [0- 9]
, but I do not know that it's fast:
/ ^ \ D {0}} (\. \ D {1,3}) $$ /
The reason your regex failed is that you have to do your first test There was a later +
sign, which means "one or more matches" therefore it is going to search for more sets at [0- 9] {0} Was, which will match the characters in any number before the tenth spot.
No comments:
Post a Comment