Regular Expressions 101

Remove useless zeroes.

Open Workspace
  • JavaScript
  • Substitution
0

Regular Expression

/
^(?<negative>\-?)(?<preceding>0?)(?<main>[0-9]+\.??[0-9]*?)(?<trailing>\.?0*)$
/
mg

Description

Replaces the string with a version that doesn't have the zeroes at the beginning or end of the string.

Submitted by Anonymous