mmedi005
asked on
Looking for a regular expression for a validator that accepts commas in a number but i don't want the decimal places....
Looking for a regular expression for a validator that accepts commas in a number but i don't want the decimal places....
i want them to be able to put 1,000,000
but not 1,000,000.00
I want whole numbers only for a validation control
How can I achieve this?
i want them to be able to put 1,000,000
but not 1,000,000.00
I want whole numbers only for a validation control
How can I achieve this?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@professionalcomputersolut ions
That didn't work for the provided example (1,000,000).
That didn't work for the provided example (1,000,000).
ASKER
Actually, let's flip that around:
1:^\d{1,3}(?:,\d{3})*|\d{1 ,3}$
That worked but I need it to work either with or without commas....can this be done?
1:^\d{1,3}(?:,\d{3})*|\d{1
That worked but I need it to work either with or without commas....can this be done?
ASKER
e.g. they should be allowed to enter:
1,000,000
or
1000000
1,000,000
or
1000000
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
"because the ^ and $ need to exclude from the alternatives" should read
"because the ^ and $ need to be excluded from the alternatives"
"because the ^ and $ need to be excluded from the alternatives"
ASKER
Perfect,
Thank you all
Thank you all
Note that if you want to be more relaxed about where the commas go, you could just use something like this:
^\d[,\d]*$
^\d[,\d]*$
ASKER
I think making them use the commas correctly is better, but thank you again...helped a lot
@TerryAtOpus
Good catch. I indeed forgot to group the expression. I must be getting older = )
will match the 100 out of the value:
Good catch. I indeed forgot to group the expression. I must be getting older = )
Open in new window