正则表达式匹配多个实例

时间:2011-06-13 10:09:27

标签: regex

我必须匹配“int(”或“der(”

)的多个实例

因此表达式必须匹配这些字符串

VVEH + int(ACC_X) + der(FL_WSP)
VVEH + int(ACC_X) + int(FL_WSP)
VVEH + der(ACC_X) + der(FL_WSP)

而不是这些

VVEH + int(ACC_X) + log(FL_WSP)
VVEH + der(ACC_X) + log(FL_WSP)

1 个答案:

答案 0 :(得分:1)

VVEH( \+ (int|der)\([^)]+\)){2,}


VVEH            #Initial string
(
    \+          #Escape the 'plus'
    (int|der)   #Either of your function names
    \(          #Escape the bracket
    [^)]+       #Match anything inside the brackets
    \)          #Escape the bracket
){2,}           #All of that stuff above at least twice