Regular Expressions 101

Community Patterns

Matches percentage with any number of digits

-4

Regular Expression
Python

r"
([0-9]*\.?[0-9]*)\s*%
"
gmi

Description

Only captures value for converting percentage to decimal. Returns empty if percentage but no value. no match = no percentage found

Submitted by sharkey - 9 years ago