Regular Expressions 101

Community Patterns

Remove useless zeroes.

0

Regular Expression
ECMAScript (JavaScript)

/
^(?<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 - a year ago