Regular Expressions 101

Community Patterns

JavaScript number literals


Regular Expression
ECMAScript (JavaScript)



Should match any valid JavaScript number literal.

Allow _ as a numerical separator, leading/trailing dot and 0, and test for prefix 0b (binary), 0o (octal), and 0x (hexadecimal).

See the second paragraph of EDIT 4 in this StackOverflow answer by me for matching JS numbers.

Submitted by MAZ01001 - 2 months ago (Last modified 2 months ago)