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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find IEEE float
Expression
[-+]?((\.[0-9]+|[0-9]+\.[0-9]+)([eE][-+][0-9]+)?|[0-9]+)
Description
Used in my SVG parser. Explanation: May start with + or -. This is followed by either an integer, or a float ("dot numbers", "numbers dot numbers" or "numbers dot" followed by an optional scientific postfix (+ or - followed by numbers) ) I'm using it to parse lists of floats, add ^$ boundaries if you want it to match whole lines.
Matches
10.2 | .0 | 3.9265e+2 | 5
Non-Matches
-one | . | whatever
Author Rating: The rating for this expression. Gaz Davidson
Source Gaz Davidson
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: Not quite correct
Name: Michael Gehricke
Date: 3/2/2018 10:25:07 PM
Comment:
1.234e5 does not match correctly, although it's a valid IEEE float. [-+]?((\.[0-9]+|[0-9]+\.[0-9]+)([eE][-+]?[0-9]+)?|[0-9]+) is correct. Just insert a question mark after [eE][-+] to make the sign of the exponent optional.


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