Regular Expressions 101

Community Patterns

Community Library Entry

-2

Regular Expression
PCRE (PHP <7.3)

/
# https://regex101.com/r/fP1oQ6/2 (?(DEFINE)# (?<W>\s*) (?<V>\d+(?:\.\d+)?(?&W)) (?<S>[-+]?) (?<O>(?&W)[-+*\/](?&W)) (?<E>(?&S)(?:(?&V)|\((?&W)(?&E)(?&W)\))(?:(?&O)(?&E))?)# )# ((?&E))
/
xgJ

Description

ValidatesMathematical Expressions. Ignores whitespace. Includes parenthesis matching.

Submitted by Jeremy Friesen - 9 years ago