.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

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -