[Solved] Construct regular expression that matches numeric expressions like 5+65 [closed]


For a simple mathematical operation like Number Operator Number you can use this regex:

^[0-9]+(\+|\-|\*|\/)[0-9]+$

For a complex expression like Number Operator Number Operator Number... try this:

^[0-9]+((\+|\-|\*|\/)[0-9]+)+$

1

solved Construct regular expression that matches numeric expressions like 5+65 [closed]