Numbersflags: g
Float / Scientific Number
Match floating-point and scientific-notation numbers including `1.5`, `.25`, `1e10`, `-3.14E-2`.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)? (flags: g)Raw source: [-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?
How it works
[-+]? matches an optional sign. (?:\d+\.?\d*|\.\d+) matches the mantissa as either digits-with-optional-decimal or decimal-with-trailing-digits. (?:[eE][-+]?\d+)? matches the optional exponent. Covers most real-number literals you'll encounter in source or data.
Examples
Input
h = 6.626e-34, c = 3e8, alpha = .007Matches
6.626e-343e8.007
Input
Range -1.5 to +2.5Matches
-1.5+2.5
Input
no numbers hereNo match
—Common use cases
- •Scientific-notation parsing in CSV/log data
- •Source-code analysis (constants extraction)
- •Lexer tooling for math DSLs
- •Data validation in physics / finance pipelines