Replace 在多行末尾添加字符

Replace 在多行末尾添加字符,replace,notepad++,Replace,Notepad++,我用的是Windows8。 这就是我所拥有的: hello 这就是我想要的: hello1 hello2 hello3 hello4 hello5 但是大约有1500个数字,这个词不是hello。 我不是任何程序员,但我可以使用记事本++,这就是我想用的。 我不想做查找:$替换为:1一千次。 我寻找答案已经有一段时间了,有人能帮我吗?我知道你喜欢记事本+,我也喜欢,但我想知道你是否能通过PowerShell解决这个问题,你已经默认在Windows 8中安装了PowerShell 此代码段将在

我用的是Windows8。 这就是我所拥有的:

hello
这就是我想要的:

hello1
hello2
hello3
hello4
hello5
但是大约有1500个数字,这个词不是hello。 我不是任何程序员,但我可以使用记事本++,这就是我想用的。 我不想做
查找:$
替换为:1
一千次。
我寻找答案已经有一段时间了,有人能帮我吗?

我知道你喜欢记事本+,我也喜欢,但我想知道你是否能通过PowerShell解决这个问题,你已经默认在Windows 8中安装了PowerShell

此代码段将在“hello”之后添加一个从1到3的递增数字。您可以轻松更改数量和单词。要运行此脚本,只需打开“开始”菜单并键入
powershell
,然后粘贴下面的行并单击绿色三角形(如果打开命令提示符,则单击enter)。我建议您打开PowerShell ISE程序,但常规shell也可以工作

1..3 | % { "hello{0}" -f $_ }
如果要将其保存到文件中,可以改为运行以下程序:

1..3 | % { "hello{0}" -f $_ } > C:\hello.txt

恭喜你!你已经写了你的第一个剧本

在记事本++中,借助插件,这是可能的。首先,从插件管理器安装Python脚本插件。接下来,使用以下代码从插件菜单创建一个新脚本:

# First we'll start an undo action, then Ctrl-Z will undo the actions of the whole script
editor.beginUndoAction()

# Initialize counter to zero
counter = 0

# Define function to append incremental value to end of search result
def increment_counter(m):
    try:
        global counter
        counter += 1
        return m.group(0) + str(counter)
    except:
        return m.group(0)

# Search for value and replace with with appended incremental result
editor.pyreplace('^hello', increment_counter)

# End the undo action, so Ctrl-Z will undo the above two actions
editor.endUndoAction()

接下来,修改要替换的文本的“hello”文本并保存脚本。最后,在记事本++中选择文件后,运行新保存的脚本。请注意,如果结果不符合您的要求,您可以撤消操作。

您可能会在此时获得更好的答案。确保提及您正在使用的操作系统。说明我正在使用的操作系统:)是否要重命名文件夹名称?动态地,您可以使用phpNope来实现这一点。这是一个文本文件。