你可以试试这个:
\[@[\w-]+(?!=)\]
的解释:
"\[" & ' Match the character “[” literally
"@" & ' Match the character “@” literally
"[\w-]" & ' Match a single character present in the list below
' A “word character” (Unicode; any letter or ideograph, digit, connector punctuation)
' The literal character “-”
"+" & ' Between one and unlimited times, as many times as possible, giving back as needed (greedy)
"(?!" & ' Assert that it is impossible to match the regex below starting at this position (negative lookahead)
"=" & ' Match the character “=” literally
")" &
"\]" ' Match the character “]” literally
希望这会有所帮助!
你试过了什么? – Sefe
\ [@(。*?)[^ = 2] \] – Sunil
单词“foo”是常量还是可以变化?另外,你只想为数字'2'或任何数字排除它? – Gurman