Notepad++ regex replace

irlmq6kh  于 7个月前  发布在  其他
关注(0)|答案(3)|浏览(87)

我有一个文本文件充满了以下行:

F randomtext
F morerandomtext

字符串
我需要什么类型的正则表达式,这样输出就像这样:

randomtext,foo
morerandomtext,foo


所以F变成了foo,并移到了行尾。

svdrlsy4

svdrlsy41#

查找:

F (.*)

字符串
全部替换为:

\1,foo

z18hc3ub

z18hc3ub2#

我想补充一点:使用Notepad++,您也可以使用正则表达式查找和替换一组文件中的内容。下面将查找所有以大写F开头的行和D中的空格的文件:\mydir -文件夹的 *.txt文件,包括子目录。
要打开Notepad++中的“在文件中查找”窗口,请键入Ctrl+Shift+F。

Find what: ^F (.*) 
Replace with: \1,foo
Filters: \1,foo
Directory: D:\mydir
Match case: Checked
In all sub-folders: Checked
Search Mode: Regular expression

字符串

kzmpq1sx

kzmpq1sx3#

使用你所展示的示例,请在你的notepad++文件中尝试下面的正则表达式。

  • 查找内容:* ^\S+\s(.*)$
    ***替换为:***\1,foo
  • regex解释:*
^\S+    ##Match from starting 1 or more occurrences of non-spaces here.
\s      ##Matching space here.
(.*)$   ##Creating one and only Capturing group which contains everything till the end of the value.

字符串

相关问题