你可以試試這個:
\[@[\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