Regular Expressions 101

Community Patterns

Any decimal numbers (floats, integers, with "." and "," with e)

1

Regular Expression
Python

r"
(([-+])?[.,]\b(\d+)(?:[Ee]([+-])?(\d+)?)?\b)|(?:([+-])?\b(\d+)(?:[.,]?(\d+))?(?:[Ee]([+-])?(\d+)?)?\b)
"
gm

Description

Matches:

  • integers [+-]?\d+([Ee][+-]?\d+)? like +45 or 96E-3 or -12e+24
  • floats starting from "." or "," like -.45e-3
  • floats starting from \d like 3.14 or -0.67E12
Submitted by anonymous - 4 years ago