将所有的"..."字符串替换成_T("...")
来源:互联网 发布:有道云笔记 ubuntu版 编辑:程序博客网 时间:2024/06/15 22:43
文章转于:VS正则表达式应用[原创]
将所有的"..."字符串替换成_T("..."),但是不能替换#include后面的字符串
由于vs的正则表达式懒惰跟贪婪控制语法不明确,只好用2条表达式来实现1. 将_T("...")转换成"..."
_T\x28{"[^"]@"}\x29
\1
2. 将"..."转换成_T("..."),其中过滤掉#include 的前缀
~(\#include:b){"[^"]@"}
_T(\1)
将两步合成一个宏,添加到IDE环境中.
Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module RecordingModule
Sub replace_str()
DTE.Windows.Item("{CF2DDC32-8CAD-11D2-9302-005345000000}").Activate() 'Find and Replace
DTE.Find.Action = vsFindAction.vsFindActionReplaceAll
DTE.Find.FindWhat = "_T\x28{""[^""]@""}\x29"
DTE.Find.ReplaceWith = "\1"
DTE.Find.Target = vsFindTarget.vsFindTargetCurrentProject
DTE.Find.MatchCase = False
DTE.Find.MatchWholeWord = False
DTE.Find.MatchInHiddenText = False
DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxRegExpr
DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResultsNone
DTE.Find.Action = vsFindAction.vsFindActionReplaceAll
DTE.Find.Execute()
DTE.Windows.Item("{CF2DDC32-8CAD-11D2-9302-005345000000}").Activate() 'Find and Replace
DTE.Find.FindWhat = "~(\#include:b){""[^""]@""}"
DTE.Find.ReplaceWith = "_T(\1)"
DTE.Find.Target = vsFindTarget.vsFindTargetCurrentProject
DTE.Find.MatchCase = False
DTE.Find.MatchWholeWord = False
DTE.Find.MatchInHiddenText = False
DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxRegExpr
DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResultsNone
DTE.Find.Action = vsFindAction.vsFindActionReplaceAll
DTE.Find.Execute()
DTE.Windows.Item("{CF2DDC32-8CAD-11D2-9302-005345000000}").Close()
End Sub
End Module
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module RecordingModule
Sub replace_str()
DTE.Windows.Item("{CF2DDC32-8CAD-11D2-9302-005345000000}").Activate() 'Find and Replace
DTE.Find.Action = vsFindAction.vsFindActionReplaceAll
DTE.Find.FindWhat = "_T\x28{""[^""]@""}\x29"
DTE.Find.ReplaceWith = "\1"
DTE.Find.Target = vsFindTarget.vsFindTargetCurrentProject
DTE.Find.MatchCase = False
DTE.Find.MatchWholeWord = False
DTE.Find.MatchInHiddenText = False
DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxRegExpr
DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResultsNone
DTE.Find.Action = vsFindAction.vsFindActionReplaceAll
DTE.Find.Execute()
DTE.Windows.Item("{CF2DDC32-8CAD-11D2-9302-005345000000}").Activate() 'Find and Replace
DTE.Find.FindWhat = "~(\#include:b){""[^""]@""}"
DTE.Find.ReplaceWith = "_T(\1)"
DTE.Find.Target = vsFindTarget.vsFindTargetCurrentProject
DTE.Find.MatchCase = False
DTE.Find.MatchWholeWord = False
DTE.Find.MatchInHiddenText = False
DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxRegExpr
DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResultsNone
DTE.Find.Action = vsFindAction.vsFindActionReplaceAll
DTE.Find.Execute()
DTE.Windows.Item("{CF2DDC32-8CAD-11D2-9302-005345000000}").Close()
End Sub
End Module
0 0
- 将所有的"..."字符串替换成_T("...")
- VS正则替换字符串,将所有的"..."字符串替换成_T("...")
- js将字符串内的所有字符串替换
- 定义一个字符串“hello world”将所有的“l”替换成“s”
- 将字符串中的所有字母都替换成该字母的下一个字母
- 使用shell命令sed将指定目录下的所有文件中指定的字符串替换成指定的字符串
- 替换所有"xxxx"为_T("xxxx")
- js替换字符串的所有
- 字符串拷贝并替换所有的字符串
- 将一个目录下所有指定文件里面的特定字符串替换
- 将一个目录下所有指定文件里面的特定字符串替换
- 将一个字符串中的所有空格替换为%20的源代码及测试用例
- js字符串替换 - 无replaceAll替换所有字符串的解决方案
- 把一个字符串中的所有的空格替换成“%20”
- 正则表达式将字符串中的所有连续空格替换成一个空格
- js将字符串中所有反斜杠\替换成正斜杠/
- js将字符串中所有反斜杠\替换成正斜杠/
- 将所有单词首字母替换成大写
- [Elasticsearch] 聚合的测试数据
- Linux 操作命令
- 高级指针
- Android 图片三级缓存机制工具类封装
- python 笔记
- 将所有的"..."字符串替换成_T("...")
- Android 开发工程师招聘要求
- Android植物大战僵尸教程学习总结(四)拓展
- 网卡如何发送和接收数据包
- Android 流式布局实现方法
- Android 自定义控件 优雅实现元素间的分割线 (支持3.0以下)
- PropertyResolver
- Android使用Path自定义波浪加载View
- Python的历史