Regular Expressions 101

Community Patterns

Match a string only for a percentage number

1

Regular Expression
PCRE (PHP <7.3)

/
(^[\d]+[\.]{0,1}[\d]*%$)
/

Description

This regex checks if a string contains a number that ends with a "%" character ignoring all other cases. 96% -> accept 96.6% -> accept kk% -> Reject 96%% -> Reject

Submitted by Krishna - 8 years ago