Scientific Notation in JS
Matches numbers in scientific/exponential notation (e.g., 1.5e10).
Try it in the JS tester →Pattern
regexJS
^-?\d+(\.\d+)?[eE][+-]?\d+$JavaScript / ECMAScript code
jsJavaScript
const re = new RegExp("^-?\\d+(\\.\\d+)?[eE][+-]?\\d+$", "");
const input = "1.5e10";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).
How the pattern works
`^-?\d+(\.\d+)?` matches a signed decimal. `[eE]` allows either exponent marker. `[+-]?\d+$` matches the signed exponent digits.
Examples
Input
1.5e10Matches
1.5e10
Input
-2.7E-5Matches
-2.7E-5
Input
3.14No match
—