Visual Studio 正则表达式中的冒号
我意识到冒号是 Visual Studio 风格的 RegEx 中的特殊字符,因此需要转义,但我在制作可选地包含单个冒号的正则表达式时遇到了麻烦。
我想向虚拟函数添加一个新参数(该参数已在很多类中被覆盖)。
所以我想找到函数名称出现在头文件中的所有位置(声明它的位置,即没有任何范围解析运算符),以及它出现在派生类名称和 a 后面的 .cpp 文件中的所有位置范围解析运算符。
(然后我会进行单独的查找和替换以捕获它被调用的所有位置)。
我认为类似的东西
FIND
{\:?Foobar\( }{int FirstParamBeforeMyChange}
REPLACE WITH
\1char MyNewFirstParam, \2
可以完成这项工作。但我没有任何喜悦。
谁能告诉我我的错误或如何做到这一点?
谢谢, G。
I realise the colon is special character in the Visual Studio flavour of RegEx and so needs to be escaped, but I was having trouble making a regular expression that optionally included a single colon.
I wanted to add a new parameter to a virtual function (that has been overriden in LOTS of classes).
So I wanted to find all the places where the function name appears in header files (where it is declared, i.e. without any scope resolution operator), and all the places it appears in the .cpp files following the name of the derived class and a scope resolution operator.
(I'd then do a separate find and replace to catch all the places where it's called).
I thought something like
FIND
{\:?Foobar\( }{int FirstParamBeforeMyChange}
REPLACE WITH
\1char MyNewFirstParam, \2
would do the job. But I had no joy.
Can anybody tell me my mistake or how to do this?
Thanks,
G.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用普通括号
()
来括起组,而不是大括号{}
。您需要将左括号转义为Foobar\(
。You need to use normal brackets
()
to enclose groups, not braces{}
. You'll need to escape up the left-bracket you have asFoobar\(
.