Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE2 (PHP >=7.3)

/
\-?\d*\.?\d+[\+\-÷%x]\-?\d*\.?\d+
/
g

Description

Matches operations with two numbers separated by the operational characters (x, -, ÷, %) ** the numbers can be negative** (can contain a - character before the number).

It also acepts decimal notation with not zero (0). Example: 0.89 and .89 are both accepted values

Acepted values example:

  • -3x+5.0
  • 784.5-.56
  • 1÷.5
Submitted by anonymous - 2 years ago