RegexWars
Tier 6 · Adeptreplace

Strip The Commas

Remove the thousands separators from a number: 1,234,567.89 becomes 1234567.89.

The mirror image of inserting separators, and far easier: deleting is just replacing with nothing. Match the commas, replace with the empty string, and remember the g flag or only the first one goes. The decimal point is not a comma and must survive untouched.

Your pattern0 chars · par 2
//
Flags
Start typing — tests run as you go.0 of 4 visible tests passing
Test cases
  • 1,234,567.89→ "1234567.89"

    the full stop stays

  • 1,000→ "1000"
  • 12,345→ "12345"
  • 42→ "42"

    nothing to strip

+ 4 hidden tests, checked when you submit. They are what stops a pattern that only fits the examples above.