在 Notepad++ 中将文本添加到多个文件的开头 [英] Adding text to the beginning of multiple files in Notepad++
问题描述
我有很多文本文件,我需要在每个文件的第一行开头添加一些文本(例如 MNP).
I have many text files, and I need to add some text (e.g. MNP) to the beginning of the first line in each file.
如何在 Notepad++ 中执行此操作?
How can I do this in Notepad++?
推荐答案
(我使用的是 v6.6.9)
(I'm using v6.6.9)
您可以使用正则表达式.互联网上的几个地方声称正则表达式 \A
有效,但它对我不起作用,它是逐字节循环的.我发现 \A^
坚持文件的 0 位置.
You can use regular expressions. Several places around the internet claim that the regex \A
works, but it wasn't working for me, it was cycling byte by byte through. I found that \A^
sticks to 0 position of the file.
奇怪的是,我还发现我无法替换\A
或\A^
并使其生效.这对我有用.
Oddly, I additionally found that I couldn't replace \A
or \A^
and have it take effect. This is what worked for me.
Find: \A^(.*?)
Replace MNP\1
说实话,替换中的 \1 甚至没有必要,因为我在作弊并且基本上是告诉记事本查找 0 个字符.
Truthfully, the \1 in Replace isn't even necessary since I'm cheating and basically telling notepad to look for 0 characters.
这应该也能正常工作.
Find: \A^.*?
Replace MNP
请事先备份您的工作.
或者,这似乎也有效.
Find: .{0}(.*)
Replace: MNP\1
它有效地查找 0 个字符,然后是整个文档/行(取决于是否检查了 .matches newline
,但是这个选择对结果无关紧要).
It effectively looks for 0 characters followed by the whole document/line (depending on whether . matches newline
is checked, this choice won't matter for the outcome however).
这篇关于在 Notepad++ 中将文本添加到多个文件的开头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!