Title |
Test
Find
Pattern Title
|
Expression |
^[+-]?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)([eE][+-]?[0-9]+)?$ |
Description |
A regular expression that matches numbers. Integers or decimal numbers with or without the exponential form. |
Matches |
23 | -17.e23 | +.23e+2 |
Non-Matches |
+.e2 | 23.17.5 | 10e2.0 |
Author |
Rating:
Erik Pettersson
|
Source |
|
Your Rating |
|
Title: Another actual case of bug being found
Name: Grace Hopper
Date: 6/1/2009 7:48:01 AM
Comment:
"-0." (minus, zero, dot) matches the regexp, though it is not a valid number.
Title: Nothing after decimal point matches
Name: Jon S.
Date: 4/21/2004 2:56:08 PM
Comment:
This expression matches numbers with a decimal point, but no digits after the decimal point, like:
100.
Title: The purpose of that part is ...
Name: BillT
Date: 2/12/2004 2:42:30 AM
Comment:
The vertical bar provides alternation in the whole group:
([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)
It would be easier to read like this;
( [0-9]*\.?[0-9]+ | [0-9]+\.?[0-9]* )
Get the idea?
Title: What is the porpouse of this part ?
Name: CV
Date: 10/24/2003 3:06:44 PM
Comment:
What is the porpouse of this part ?
[0-9]+|[0-9]+
Can't it do the same with just [0-9]+ ?
What is the difference ?