Regular Expressions 101

Community Patterns

Match simple mathemathics expressions

0

Regular Expression
ECMAScript (JavaScript)

/
[^a-zA-Z,]\d+((\,\d+(\+|\-|\*|\/)\d+(\,\d+|))|((\+|\-|\*|\/)(\d+(\,\d+|))))
/
g

Description

This regexp matches for example that: 10+10 10,0+9,9 10,0+9 10+9,9 allowed operations are: +,-,/,*

This regexp ignore for example that: 10 +10 10+ 10 10+1 0 1 0+10 a10+10 ,10+10 ,1,0+10 and so on.

Submitted by Dominik - 7 years ago