英文:
Adding trailing text to specific lines
问题
I need to add a trailing thxt to lines, but only to lines which begins with a specific text.
Example:
AAA First Line text
BBB Second line text
I need to add the trailing text only to lines which begins with BBB, so, supposing to add "with trailing text", the final result will be:
AAA First Line text
BBB Second line text with trailing text
Any idea about how to obtain this?
Tried with some regular expression and substitution, but I can't find a way to impose the condition that only lines beginning with something specific will get the trailing text.
英文:
I need to add a trailing thxt to lines, but only to lines which begins with a specific text.
Example:
AAA First Line text
BBB Second line text
I need to add the trailing text only to lines which begins with BBB, so, supposing to add "with trailing text", the final result will be:
AAA First Line text
BBB Second line text with trailing text
Any idea about how to obtain this?
Tried with some regular expression and substitution, but I can't find a way to impose the condition that only lines beginnig with something specific will get the trailing text
答案1
得分: 0
在Notepad++的替换对话框中,您需要点击右下角的正则表达式单选按钮。然后您可以:
- 查找:
^(BBB.*)$
- 替换:
\1 with trailing text
工作原理如下:
^...$
表示整行而不仅仅是其中的一部分(...)
表示捕获此文本为\1
BBB.*
表示BBB后面跟着0个或多个任意字符\1
表示将其替换为先前捕获的内容
英文:
In Notepad++ on the Replace dialog you need to click the Regular Expression radio button at the bottom right. Then you can:
- Find:
^(BBB.*)$
- Replace:
\1 with trailing text
How that works is:
^...$
means the entire line instead of just part of it(...)
means capture this text as\1
BBB.*
means BBB followed by 0 or more of any character\1
means replace this with whatever was captured earlier
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论