[
and ]
are special characters in regular expressions, so you need to escape them. This should work for you:
[.*?]
.*?
does non-greedy matching of any character. The non-greedy aspect assures that you will match [abc]
instead of [abc]def]
. Add a leading ^
and trailing $
if you want to match the entire string, e.g. no match at all in abc[def]ghi
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…