Regular Expressions 101

Community Patterns

[Fixed] Parse all simple math expressions (decimal, negative, whole)

1

Regular Expression
PCRE (PHP <7.3)

/
([\d]+[.][\d]+)|([\d]+)|([\+\-\*\/\^]+)|([\(\)])*
/
g

Description

Includes +, -, /, *, and ^. Can parse decimals. Can parse negative whole numbers and decimals. Can parse parentheses.

Used only for parsing math expressions using regex.

Submitted by anonymous - 8 years ago