简体   繁体   English

适用于Notepad ++的Python脚本中的可选参数

[英]Optional arguments in Python Script for Notepad++

I'm trying to automize deleting of some text on a HTML code I'm editing on Notepad++. 我正在尝试自动删除在Notepad ++上编辑的HTML代码上的某些文本。 I've figured out the plugin "Python Script" would be a good option. 我发现插件“ Python Script”将是一个不错的选择。

It seems to me I should use Editor.rereplace working as follow: 在我看来,我应该使用Editor.rereplace如下工作:

Editor.rereplace(search, replace[, flags[, startPosition[, endPosition[, maxCount]]]]) 

Only problem is that I want to use the optional argument "maxCount" but not "flags", "startposition" and "endposition" 唯一的问题是我要使用可选参数“ maxCount”,而不要使用“ flags”,“ startposition”和“ endposition”

I've tried coding this: 我试过编写此代码:

Editor.rereplace("old", "new", maxCount=1)

That does not work, I guess because it's not really Python but Scintilla language. 我猜这行不通,因为它不是真正的Python,而是Scintilla语言。 So I've looked out on Scintilla documentation and it seems to me, optional argument does not exist "naturaly" in Scintilla. 因此,我查看了Scintilla文档,在我看来,Scintilla中不存在可选参数。

The syntax is defined as [opt1 [opt2 [opt3]]] and not [opt1] [opt2] [opt3] which means you cannot use opt3 without also specifying opt1 and 2. Why not just supply values for the flags, start and end positions that work for you? 语法定义为[opt1 [opt2 [opt3]]]而不是[opt1] [opt2] [opt3] ,这意味着您不能在未指定opt1和2的情况下使用opt3。为什么不只为标志,开始和结束提供值适合您的职位?

I would try: 我会尝试:

Editor.rereplace("matchRegex", "replaceWith",0,0,1,1)

Where: 哪里:

Flags: 0
Start: 0
End: 1
MaxCount: 1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM