.net - Matching numbers with regular expressions — only digits and commas -
.net - Matching numbers with regular expressions — only digits and commas -
i can't figure out how build regex illustration values:
123,456,789 -12,34 1234 -8
could help me?
if want allow digits , commas, ^[-,0-9]+$
regex. if want allow spaces, utilize ^[-,0-9 ]+$
.
however, if want allow proper numbers, improve go this:
^([-+] ?)?[0-9]+(,[0-9]+)?$
or utilize .net's number parser (for various numberstyles, see msdn):
try { double.parse(yourstring, numberstyle.number); } catch(formatexception ex) { /* number not in accepted format */ }
.net regex numbers matching
Comments
Post a Comment