Regular Expressions 101

Community Patterns

Remove common numeric suffixes (eg: 40m, 60%)

4

Regular Expression
PCRE (PHP <7.3)

/
\b([\d\.]+)[mkb%](?!\S)
/
ig

Description

Usage: "40%".replace(/\b([\d.]+)mkb%/ig, '$1')

Submitted by anonymous - 9 years ago