RegEx BackReference to Match Different Values

前端 未结 2 1877
栀梦
栀梦 2020-11-28 16:31

I have a regex that I use to match Expression of the form (val1 operator val2)

This regex looks like :

(\\(\\s*([a-zA-Z]+[0-9]*|[0-9]+|\         


        
2条回答
  •  悲&欢浪女
    2020-11-28 17:31

    What language/application are you using this regular expression in? If you have the option you can specify the different parts as named variables and then build the final regular expression by combining them.

    val = "([a-zA-Z]+[0-9]*|[0-9]+|\'.*\'|\[.*\])"
    op = "(ni|in|\*|\/|\+|\-|==|!=|>|>=|<|<=)"
    exp = "(\(" .. val .. "\s*" .. op .. "\s*" .. val .. "\))"
    

提交回复
热议问题