Visual Studio 在字符类中查找并替换右方括号 ] [英] Visual Studio find and replace right square bracket ] in character class

查看:42
本文介绍了Visual Studio 在字符类中查找并替换右方括号 ]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个否定字符类来匹配这样的方括号标签[方括号标签].问题是,] 字符结束了字符类!

I want to make a negated character class to match a square bracket tag like this [square bracket tag]. The problem is, the ] character ends the character class!

我试过了

\[[^\]]+]

但是当我运行它时出现语法错误.(这是在查找和替换正则表达式引擎中,它与标准 .NET 引擎仅供参考)略有不同.

but I get a syntax error when I run it. (This is in the find and replace regex engine which is slightly different than the standard .NET engine fyi).

推荐答案

你忘了转义最后的结束括号:

You forgot to escape the final end bracket:

\[[^\]]+\]

这篇关于Visual Studio 在字符类中查找并替换右方括号 ]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆