Ec (2); php tutorial Regular Expression examples (suitable for beginners) mathematical formula Regular Expressions :(? Kh () * ([-+]) {0, 1} [0-9.] + (? -Kh) * ([+-*] {1 }(? Kh ()*((? & Lt; () ([-+]) {0, 1 })? [0-9.] + (? -Kh) *) + (? (Kh )(?!)) Match the mathematical formula of addition, subtraction, multiplication, division, for example: (1 + 2)-3*4 )(? Kh () * ([-+]) {0, script ec (2); script
Php tutorial Regular Expression examples (suitable for beginners)
Regular Expressions of mathematical formulas:
(? 'Kh' () * ([-+]) {0, 1} [0-9.] + (? '-Kh') * ([+-*/] {1 }(? 'Kh '()*((? <= () ([-+]) {0, 1 })? [0-9.] + (? '-Kh') *) + (? ('Kh ')(?!))
Match the mathematical formula of addition, subtraction, multiplication, division, for example: (1 + 2)-3*4)
(? 'Kh' () * ([-+]) {0, 1} [0-9.] + (? '-Kh') * ([+-*/] {1 }(? 'Kh '()*((? <= () ([-+]) {0, 1 })? [0-9.] + (? '-Kh') *) + (? ('Kh ')(?!))
Yes. ("START, press into the stack to count the number of parentheses. * indicates that the number of braces can appear 0 or multiple times.
(? 'Kh' () * ([-+]) {0, 1} [0-9.] + (? '-Kh') * ([+-*/] {1 }(? 'Kh '()*((? <= () ([-+]) {0, 1 })? [0-9.] + (? '-Kh') *) + (? ('Kh ')(?!))
A positive or negative sign can appear.
(? 'Kh' () * ([-+]) {0, 1} [0-9.] + (? '-Kh') * ([+-*/] {1 }(? 'Kh '()*((? <= () ([-+]) {0, 1 })? [0-9.] + (? '-Kh') *) + (? ('Kh ')(?!))
0-9 digits, one or more
(? 'Kh' () * ([-+]) {0, 1} [0-9.] + (? '-Kh') * ([+-*/] {1 }(? 'Kh '()*((? <= () ([-+]) {0, 1 })? [0-9.] + (? '-Kh') *) + (? ('Kh ')(?!))
Can be ")" ended. The number of statistical parentheses in the stack is displayed. * indicates that the number of statistical parentheses can appear 0 or multiple times.
(? 'Kh' () * ([-+]) {0, 1} [0-9.] + (? '-Kh') * ([+-*/] {1 }(? 'Kh '()*((? <= () ([-+]) {0, 1 })? [0-9.] + (? '-Kh') *) + (? ('Kh ')(?!))
The orange brackets can be grouped once or multiple times. For example, if the formula is 1 + 2, the brackets match 2.
Red requirement +-*/appears once
(? 'Kh' () * ([-+]) {0, 1} [0-9.] + (? '-Kh') * ([+-*/] {1 }(? 'Kh '()*((? <= () ([-+]) {0, 1 })? [0-9.] + (? '-Kh') *) + (? ('Kh ')(?!))
When the brackets start to be judged, there can be positive and negative signs ,? It indicates that when a slot match is used, for example, 1 + (2-3) + 4) + 5), only one bracket before the number 2 is matched.
(? 'Kh' () * ([-+]) {0, 1} [0-9.] + (? '-Kh') * ([+-*/] {1 }(? 'Kh '()*((? <= () ([-+]) {0, 1 })? [0-9.] + (? '-Kh') *) + (? ('Kh ')(?!))
Check whether parentheses are paired