Page 1 of 1

match a specific decimal number 0.666666

Posted: Sat Jan 29, 2011 9:03 am
by rtaylor
Hi,

I am entirely new to regex. I need to use regular-expression to match correct answers for an online quiz. Is there any expression for matching a decimal number that may be entered in a number of different ways. For example,

0.666666...

could match
.66, .67, .66666, .667, 0.6667 etc.

thanks,

~russ

Re: match a specific decimal number 0.666666

Posted: Sun Jan 30, 2011 3:02 pm
by greyhoundcode
How about this one:

Code: Select all

^0?\.6+7?$
You'd need to trim out any whitespace from the answer first of all.