【发布时间】:2020-10-01 21:43:26
【问题描述】:
我目前正在使用 oniguruma 正则表达式来搜索功能类似的匹配项,但某些关键字除外。例如,在字符串中 "这是一个 test() 和 im() testing() thi[s]() this_[is]_a_fun(with,some,params)"
正则表达式应该匹配:
test,
im,
testing,
thi[s]
this_[is]_a_fun
我正在使用的当前正则表达式是
\s*([A-z0-9\w_]+).?(?=\()(\b(?<!if|while|for|return|else|elif|equals|or|xor|and|not|le|gre))
但这不匹配 thi[s] 或单词中包含括号的任何函数。
我尝试更新正则表达式以将这些模式与正则表达式匹配
\s*([A-z0-9\w_|\[|\]]+).?(?=\()(\b(?<!if|while|for|return|else|elif|equals|or|xor|and|not|le|gre))
但无济于事。
任何匹配这些模式的帮助将不胜感激
【问题讨论】:
标签: regex match special-characters regex-negation oniguruma