Visual Studio find and replace the right square bracket] in the character class

I want the negative character class to match a tag with a square bracket like this [square bracket]. The problem is that the character] ends the character class!

I tried

\[[^\]]+] 

but when I start, I get a syntax error. (This is in the regex search and replace mechanism, which is slightly different from the standard fyi .NET engine).

+9
source share
3 answers

You forgot to leave the final ending bracket:

 \[[^\]]+\] 
+3
source

The first example in msdn uses \\ to escape \ , which then exits . . Therefore, you should do something like \\[[^\\]]+\\] , as well as Damien_The_Unbeliever said that you did not close the end bracket.

0
source

I definitely expected to exit with "\", but it didn’t work for me (grep @MacOS), but this: [^]] did the job. Just put] as the first character in the class. I actually used something like: [^]?[]

-one
source

All Articles