Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I need to write a regular expression which allows numbers and Comma

Basically user can enter amount with comma and dot like
@20.22 or 2,010.00

Expression which allows numbers is this but now how to modify the expression to satisfy the requirement.
Regex m = new Regex("^[0-9]");


Please let me know the changes for this,thanks in advance.....
Posted

Try tools like:
Regexp Editor[^]
RegexLib[^]

Form the regular expressions the way you want. Try it.
 
Share this answer
 
It would go something like this:
^(((([0-9]{1,3},)([0-9]{3},)*[0-9]{3})|[0-9]{1,3})(\.[0-9]+)?)$

You'd have to modify that a bit if you want to exclude leading zeros. If you do want to do that, I recommend you take Sandeep's suggestion and look into constructing it yourself using some of the useful tools freely available to you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900