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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Find standalone integers
Expression
(?<!\.)(?<!e[+-])(\b\d+\b)(?!\.)
Description
Locates standalone integers, like the 1 and 4 in 1/4, but doesn't match the 5 in 6e-5 (nor the 6, in fact). I use this to convert 1/4 to 1.0/4.0 so that it can be evaluated as a floating number, since 1/4 by itself will normally eval to 0 (integer division). However, 6e-5.0 would not be valid.
Matches
1/4 | 1e-2+1/4 | 1.2+4/7
Non-Matches
1.9e-2 | 1e+3 | 1e4
Author Rating: Not yet rated. Anders Blom
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

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