Regular Expressions 101

Community Patterns

Community Library Entry

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