I want to find a specific word in a text, but not the ones that surrounded with a special char, or tag, etc.
For example:
This word should be find, but [this word] shouldn't.
Is it possible to do this with Regular Expression? Or I should thi开发者_StackOverflownk about writing a special parser?
Thanks.
Try the following
(^|[^\[])[Tt]his word($|[^$\]])
(^|[^\[])
-> line start or everything except an opening square bracket
[Tt]his word
-> make the first letter case insensitive
($|[^\]])
-> line end or everything except an closing square bracket
精彩评论