Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
ECMAScript (JavaScript)

/
^\-?[0-9]+\.??[0-9]*?(?=\.?0*$)
/
gm

Description

Given a number it will match said number exept any trailing zeroes behind a decimal point or said decimal point if there would be no matched characters behind it. Some applications use trailing zeroes to denote precision. If your application wants to remove said trailing zeroes before displaying them this regex could be used.

Submitted by anonymous - 2 years ago (Last modified 2 years ago)