PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Thu Sep 20, 2018 10:32 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sat Jan 29, 2011 10:03 am 
Offline
Forum Newbie

Joined: Sat Jan 29, 2011 9:56 am
Posts: 1
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


Top
 Profile  
 
PostPosted: Sun Jan 30, 2011 4:02 pm 
Offline
Forum Regular
User avatar

Joined: Mon Feb 11, 2008 5:22 am
Posts: 613
How about this one:
Code:
^0?\.6+7?$

You'd need to trim out any whitespace from the answer first of all.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group