Regular Expressions 101

Community Patterns

Simple math term parser

1

Regular Expression
ECMAScript (JavaScript)

/
^(-?\d+(\.\d+)?)(\+|-|\*|\/)(\d+(\.\d+)?|\(-\d+(\.\d+)?\))$
/

Description

This regex can be used for parsing simple math terms. You can use this operations: + - * / For example: 1+2 1.9/8.9 -810.123-98 810*(-1.12)

Submitted by anonymous - 8 years ago