.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

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -