Regular Expressions 101

Community Patterns

Numbers (signed, integers, decimals, ...)

1

Regular Expression
ECMAScript (JavaScript)

/
(?<sign>[+-])?(?<int>\d(?:[\d_ ]*\d+)?)(?:(?:\s*[,.]\s*)(?<decimal>\d(?:[\d_ ]*\d+)?))?
/
g

Description

  • Integers
  • Decimal value starts by comas or dots
  • Handle spaces, "_" characters
  • Signed or not

--> Visit https://flymeth.net to view my works

Submitted by anonymous - 21 days ago