简体   繁体   中英

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++. I've figured out the plugin "Python Script" would be a good option.

It seems to me I should use Editor.rereplace working as follow:

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"

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. So I've looked out on Scintilla documentation and it seems to me, optional argument does not exist "naturaly" in 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?

I would try:

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

Where:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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