我有一个C++源文件,它使用getMemberName()形式的函数来返回成员数据.相反,我想使用memberName().
为了匹配需要更改的函数名称的实例,我使用以下正则表达式:
(\s+)get([A-Z])
Run Code Online (Sandbox Code Playgroud)
问题是,我不知道如何用小写版本替换\ 2的实例.有没有人有任何想法,或者我应该编写Perl脚本?
谢谢,
扎克
Mat*_*att 10
注意:此功能在Notepad ++中通过\L\1\E正则表达式替换模式提供.
\L 小写的\2 匹配组2\E 小写关闭,以防您有任何进一步的替换. 像往常一样,有另一种方式.这可以在带有PythonScript插件的Notepad ++中完成,以及其他任何超出notepad ++中可用范围的内容,而无需编写完整的插件.
首先,在Notepad ++中安装PythonScript插件
插件>插件管理器>显示插件管理器
在"可用"选项卡中选中"Python脚本",然后单击"安装",然后重新启动Notepad ++
然后设置一个Python脚本
插件> Python脚本>新脚本
给它一个有用的名字
添加以下代码
# Start a sequence of actions that is undone and redone as a unit. May be nested.
editor.beginUndoAction()
# trimFunctionName - for editor.pysearch
def trimFunctionName( index, match ):
editor.pyreplace( match.re, match.group(1) + match.group(2).lower(), 1, 0, index, index )
# I couldn't work out how to jam the .lower call into a editor.pyreplace()
# so used editor.pysearch() to check the regex and run a function with match
# information
editor.pysearch(r'(\s+)get([A-Z])', trimFunctionName )
# end the undo sequence
editor.endUndoAction()
Run Code Online (Sandbox Code Playgroud)
然后运行脚本.
插件> Python脚本>脚本>"yourScript"
您可以使用提供的对象提示用户输入或对scintilla执行大量其他操作
小智 8
这是一个非常基本的HTML标记转换器(小写):
左键单击搜索 - > 替换(或CTRL H).
在相应的字段中输入以下内容:
找什么: <([^>]+?)>
用...来代替: <\L\1>
左键单击全部替换.
完成