RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

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: The rating for this expression. Erik Pettersson
Source
Your Rating
Bad Good

Enter New Comment

Title
 
Name
 
Comment
 
Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

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 ?


Copyright © 2001-2018, RegexAdvice.com | ASP.NET Tutorials