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

Please support RegExLib Sponsors

Sponsors

Expressions by User

   Displaying page 1 of 1 pages; Items 1 to 1
Title Test Details 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
   Displaying page 1 of 1 pages; Items 1 to 1

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