
November 26th, 2008, 12:26 PM
|
|
Registered User
|
|
Join Date: Nov 2008
Posts: 14
Time spent in forums: 1 h 51 m 35 sec
Reputation Power: 0
|
|
|
Another Regex
My brain is starting to get into it, but not quite.
I want to check for a float number, which would accept all of the following:
1
1.1
.1
0 through 999
remove spaces surrounding
return the entire number
it should not accept:
.
letters, etc...
Here's my expression so far:
^\s*((?:[0-9]{1,3}(?:\.[0-9]*)?)|(?:.[0-9]+))\s*$
Here's what I THINK it does--please correct me (since I'm obviously wrong):
EITHER
3 digits, optional decimal by unlimited digits
OR
decimal, unlimited digits
but it accepts 131313. I don't understand why. It shouldn't accept anything larger than 3 digits (999).
Help is appreciated.
Jay
|