我正在尝试自动删除我在Notepad ++上编辑的HTML代码上的某些文本,我正在使用插件PythonScript来执行此操作。我只有一个问题:例如,我想要删除除第一个之外的所有<center>
。我以为我可以使用这个功能:
Editor.rereplace("search", "replace"[, flags[, startPosition[, endPosition[, maxCount]]]])
由于我不想删除第一个术语,我可以将startPosition
设置为第一个术语之后的一行。唯一的问题是我找不到任何闪烁函数用于查找我要查找的文本的Python脚本。也许这个research
函数可以帮助找到解决方案:
Editor.research(search, matchFunction[, flags[, startPosition[, endPosition[, maxCount]]]])
但我找不到与.research相关的任何能帮助我的功能。
答案 0 :(得分:2)
matches = []
def match_found(m):
# append the match start position to the matches array
matches.append(m.end(0))
editor.research('pattern', match_found)
matches[0] #should now contain the index of the *end* of the first match
m.end()
因为你想使用匹配结束作为下一次搜索的开始