正则表达式替换

5

我需要在文件中用:something替换"something"。 我的编辑器是Kate,有没有人能建议一个搜索表达式和占位符。

Example

Input

"code"
"name"
"remark"

Output

:code
:name
:remark
3个回答

12

搜索 "(\w+)",替换为 :\1


1
我期待对“(\w+)”和\1的解释。它们是什么? - Biju CD
3
搜索教程中的分组和回溯引用 - dfa
@dfa 我能用Perl s/g命令吗? - Biju CD
一篇关于此问题/答案的博客文章:http://labs.sasslantis.ee/2012/05/kate-and-replace-with-regular-expressions/ - Gerald Senarclens de Grancy
运行得非常好。谢谢。强调需要使用括号。我曾经将单行风格注释(cpp)替换为多行风格注释(c ansi)。搜索:(//)(.*) 替换:/* \2 */非常有用。 - DrBeco

3

搜索:(某物)
替换为::\1


0
为什么简单的搜索和替换不适用? 模式:something 替换为::something


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接