regexhelper
Test a pattern. Copy a ready-made one. No signup.

Regex to Match Scientific Notation

Copy the pattern, paste your data, and watch each E-notation number light up. Below: the mantissa and exponent explained.

/ /

What this pattern matches

It matches a number written in scientific (E) notation: a mantissa, the letter e or E, and a signed integer exponent.

Part by part

[-+]? — an optional leading sign on the mantissa.

\d+(?:\.\d+)? — the mantissa, with an optional fractional part.

[eE] — the exponent marker.

[-+]?\d+ — the signed integer exponent.

Notes

This requires an exponent, so plain 42 and 2.5 do not match. To accept an optional exponent, wrap the last part in a group: (?:[eE][-+]?\d+)?.

Use it in your code

Python
import re
text = "6.02e23, -1.6E-19, 3e8, 1.0e+10, 42, 2.5"
pattern = r'''[-+]?\d+(?:\.\d+)?[eE][-+]?\d+'''
for m in re.finditer(pattern, text):
    print(m.group())
JavaScript
const text = "6.02e23, -1.6E-19, 3e8, 1.0e+10, 42, 2.5";
const re = new RegExp(String.raw`[-+]?\d+(?:\.\d+)?[eE][-+]?\d+`, "g");
console.log(text.match(re));

FAQ

Does it require the exponent?

Yes — by design, so it isolates E-notation values. Make it optional with (?:[eE][-+]?\d+)? to match ordinary numbers too.

Does it allow a mantissa like '.5e3'?

No, it requires at least one digit before the point. Use \d*\.?\d+ for the mantissa to allow a leading dot.

Is the exponent allowed to be a decimal?

No. Exponents are integers in standard scientific notation, so the pattern uses \d+ there.