c# - Regular Expression almost perfect for a Numeric Value -
I have this regg almost correct ... it seems that except A number that happens with a negative signal and then decimals if I enter:
- 2.
I get an error I get it -
Here's my reggae - everything else 'I've totally tested ...
^ (\ + | -)? [0- 9] {1,11}? (?: [[0- 9] {1, - Number to 11 digits (99 billion)
- Positive or negative: $
All these tasks:
-0.2345 -10 12.15 0.1245 5.555 25000000000 (aka 25 billion) 25000000000.25
< / Pre>These do not work:
- 2-421
Try this:
^ (\ + | -)? [0- 9] {011}? (?: \. [0- 9 ] {1, 4})? $
Up Aet:
Accepts the above regex string +
, -
and
(empty string). To prevent those people, use lookhead , the lookhead ensures that a letter should be followed by +
or -
.
The correct solution is:
^ (\ + | -)? (? =. {1}) [0- 9] {0,11} (?: [[0- 9] {1,4})? $ String
>
string not accepted:
100000000000.0001 + - 1234567890121111111111.12345 +1.1.1.1 -2
Comments
Post a Comment