Regular Expressions 101

Library entries

Advanced Currency Matcher/Validator

Vote

0

Regular Expression
pcre

/
(?(DEFINE) (?<currency_symbol> \p{Sc} ) (?<leading_group> [1-9] \d{0,2}+ ) (?<group> \d{3} ) (?<non_leading_groups> (?&group) (?:(?&group_delim)(?&group))*+ ) (?<decimal_delim> (?# Use the opposite of group_delim. ) (?(group_delim_comma) \. | (?(group_delim_period) , | [,.] (?# There's no definitive grouping_delim. ) ) ) ) ) ^ (?> (?&currency_symbol) (?&leading_group) (?: (?<group_delim> (?<group_delim_comma> , ) | (?<group_delim_period> \. ) | \ (?# Allow whitespace as a delimiter. ) ) (?&non_leading_groups) | \d*+ (?# It's also possible that there's no delimiter. ) ) ) (?: (?&decimal_delim) \d*+ )?+ $
/
guxm

Description

Loading markdown...
Submitted by Paul Buonopane (Zenexer) - 6 years ago