gpt4 book ai didi

notepad++ - 可以在所有行的末尾添加 0-99 之间的数字吗?

转载 作者:行者123 更新时间:2023-12-05 05:30:03 25 4
gpt4 key购买 nike

你好,我有一些格式:

Marcin:Marcin
Pawel:Pawel

我想在行尾添加 0-99 之间的数字,所以结果应该是这样的:

Marcin:Marcin1
Marcin:Marcin2
..
Marcin:Marcin99
Pawel:Pawel1
Pawel:Pawel45
..
Pawel:Pawel99

etc.

有没有什么命令或插件可以做到这一点?

我手动尝试过,但太浪费时间了,我也尝试在谷歌上找到它,但没有结果。

最佳答案

您可以在 PythonScript 插件中运行 python 脚本。

如果尚未安装,请按照此 guide

  • 创建脚本(插件 >> PythonScript >> 新脚本)
  • 复制此代码并保存文件(例如 insert_num.py):
import re

def insert_num(match):
strout = ''
maxcount = 100
for counter in range(1, maxcount):
strout += match.group() + str(counter)
if counter < maxcount - 1:
strout += "\n"
return strout

editor.rereplace(r'^.+(?<!\d)$', insert_num)
  • 打开你要修改的文件
  • 运行脚本(插件 >> PythonScript >> 脚本 >> insert_num)
  • 完成

给定示例的结果:(缩短)

enter image description here

关于notepad++ - 可以在所有行的末尾添加 0-99 之间的数字吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74804128/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com