Regular Expressions 101

number selector, with commas & decimals

Open Workspace
  • PCRE2 (PHP)
  • Match
1

Regular Expression

/
(?P<isminus>-)? (?P<number> (?P<justdecimal> (?P<justdecpoint>\.) (?P<justdecdigits>\d+) ) | (?P<integer> (?P<withcommas> (?:\d{1,3}) (?:,\d{3})+ ) | (?P<nocommas>\d+) ) (?P<decimal> (?P<decpoint>\.) (?P<decdigits>\d+) )? )
/
gmx

Description

selects numbers, with commas and decimals, like 1,234.56

Submitted by Bicorn