在 Notepad++ 中使用 RegEX 进行前缀和追加 [英] Using RegEX To Prefix And Append In Notepad++

查看:105
本文介绍了在 Notepad++ 中使用 RegEX 进行前缀和追加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 txt 文件中有相当多的单词列表,我正在尝试在 Notepad++ 中进行正则表达式查找和替换.我需要在每行之前和每行之后添加一个字符串..这样:

<前>wordone词二词三

成为

<前>能够:wordone"能够:wordtwo"能够:wordthree"

我该怎么做?

解决方案

假设是字母数字,可以使用:

搜索 = ^([A-Za-z0-9]+)$替换 = 能够:"\1"

或者,如果您只想突出显示线条并使用全部替换"&在选择中"(具有相同的替换):

搜索 = ^(.+)$

^ 指向行首.
$ 指向行尾.

\1 将是括号内的源匹配项.

I have quite a large list of words in a txt file and I'm trying to do a regex find and replace in Notepad++. I need to add a string before each line and after each line.. So that:

wordone
wordtwo
wordthree

become

able:"wordone"
able:"wordtwo"
able:"wordthree"

How can I do this?

解决方案

Assuming alphanumeric words, you can use:

Search  = ^([A-Za-z0-9]+)$
Replace = able:"\1"

Or, if you just want to highlight the lines and use "Replace All" & "In Selection" (with the same replace):

Search = ^(.+)$

^ points to the start of the line.
$ points to the end of the line.

\1 will be the source match within the parentheses.

这篇关于在 Notepad++ 中使用 RegEX 进行前缀和追加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆