Text Processingflags: g

JSON Number (Strict)

Match JSON-spec numbers — disallows leading zeros (no `01`), allows decimals and exponents.

Try it in RegexPro →

Available in

Pattern

regexengine-agnostic
-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][-+]?\d+)?   (flags: g)

Raw source: -?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][-+]?\d+)?

How it works

-? optional sign. (?:0|[1-9]\d*) the integer part: either a single zero or a non-zero digit followed by any digits (no leading zeros allowed per RFC 8259). (?:\.\d+)? optional decimal part. (?:[eE][-+]?\d+)? optional exponent. Strict per JSON spec — won't match `01` or `1.` (which are valid JS but not JSON).

Examples

Input

values: 0, 42, -3.14, 6.022e23

Matches

  • 0
  • 42
  • -3.14
  • 6.022e23

Input

0.5 vs invalid 01

Matches

  • 0.5
  • 0
  • 1

Input

no numbers

No match

Common use cases

  • JSON validators and lexer fallback paths
  • Number-extraction from semi-JSON formats
  • Detecting JS-isms in JSON payloads
  • Quick parsing in observability pipelines