在特定行的末尾添加文本
Add text at the end of specific lines
我知道如何在每一行的末尾添加一些内容,但是如何在包含特定单词的行的末尾添加文本。
Some line of text here
Tomatoes Oranges
Mili Deci Centi
Some line of text there
Fire Flame
Dog Cat
Tall Small
Some line of text with more text
Mother farher
-------
我想在包含 "Some line" 的行的末尾添加字符,如下所示:
Some line of text here EXTRATEXT
Tomatoes Oranges
Mili Deci Centi
Some line of text there EXTRATEXT
Fire Flame
Dog Cat
Tall Small
Some line of text with more text EXTRATEXT
Mother farher
-------
行以不同的字符结尾,因此我需要搜索行内的模式,并在这些行的末尾添加文本。
[a-zA-Z]+\n
或 \w+\n
或多个 \n+
如果你也想清理空行。最后,如果单词首字母大写很重要:[A-Z][a-zA-Z]+\n
替换以下模式:
Some line.*
有:
[=11=] EXTRATEXT
这匹配从 Some line
到行尾(.*
,因为 .
匹配除换行符之外的任何字符)。
然后您可以将整个匹配项 ([=15=]
) 替换为自身,后跟您想要的额外文本。
为什么不尝试使用换行符或回车符来分隔正则表达式模式 return。
我认为可以在 Notepad++ 上使用正则表达式末尾的 \r\n 来实现。
我知道如何在每一行的末尾添加一些内容,但是如何在包含特定单词的行的末尾添加文本。
Some line of text here
Tomatoes Oranges
Mili Deci Centi
Some line of text there
Fire Flame
Dog Cat
Tall Small
Some line of text with more text
Mother farher
-------
我想在包含 "Some line" 的行的末尾添加字符,如下所示:
Some line of text here EXTRATEXT
Tomatoes Oranges
Mili Deci Centi
Some line of text there EXTRATEXT
Fire Flame
Dog Cat
Tall Small
Some line of text with more text EXTRATEXT
Mother farher
-------
行以不同的字符结尾,因此我需要搜索行内的模式,并在这些行的末尾添加文本。
[a-zA-Z]+\n
或 \w+\n
或多个 \n+
如果你也想清理空行。最后,如果单词首字母大写很重要:[A-Z][a-zA-Z]+\n
替换以下模式:
Some line.*
有:
[=11=] EXTRATEXT
这匹配从 Some line
到行尾(.*
,因为 .
匹配除换行符之外的任何字符)。
然后您可以将整个匹配项 ([=15=]
) 替换为自身,后跟您想要的额外文本。
为什么不尝试使用换行符或回车符来分隔正则表达式模式 return。
我认为可以在 Notepad++ 上使用正则表达式末尾的 \r\n 来实现。