Regular expression to match digits and basic math operators

前端 未结 9 1882
孤城傲影
孤城傲影 2020-12-03 05:49

I need a regular expression that will match 0-9, (,),+,-,* and /.

9条回答
  •  心在旅途
    2020-12-03 06:50

    It looks like you might be trying to match numeric expressions like 5+7-3.

    This should match them :

    ([-+]?[0-9]*\.?[0-9]+[\/\+\-\*])+([-+]?[0-9]*\.?[0-9]+)
    

提交回复
热议问题