这些天做discuz插件,体验到了正则表达式的强大,恰好在notepad++里注意到了正则替换,于是试了下
待替换的文本:
想要的格式如下:
索引 = 内容
其中,索引为 href属性中的css文件名(不含扩展名),内容为 title属性。如果普通替换,可以得到内容 = 索引 格式的结果,可是剩下的就得手动替换了。
用正则表达式,一步就可以搞定,正则式为:
.+=\".+\".+=\"(.+)\".+=\"\w+\/(.+)[.].+
替换规则:
\2 = \1
替换后结果:
default = Default
dark = Dark
far = FAR
idea = IDEA
sunburst = Sunburst
zenburn = Zenburn
vs = Visual Studio
ascetic = Ascetic
magula = Magula
github = GitHub
googlecode = Google Code
brown_paper = Brown Paper
school_book = School Book
ir_black = IR Black
solarized_dark = Solarized - Dark
solarized_light = Solarized - Light
arta = Arta
monokai = Monokai
xcode = XCode
pojoaque = Pojoaque
rainbow = Rainbow
tomorrow = Tomorrow
tomorrow-night = Tomorrow Night
tomorrow-night-bright = Tomorrow Night Bright
tomorrow-night-blue = Tomorrow Night Blue
tomorrow-night-eighties = Tomorrow Night Eighties
来自:annhe.net
以上就是Notepad++使用正则表达式替换字符串(索引=内容)的详细内容,更多请关注易知道|edz.cc其它相关文章!