Kenny:
--------------------------------------------------------------------------------
Argh, too bad I have zero knowledge about these kind of languages.

It's close to impossible to do such a thing I guess, right ?
--------------------------------------------------------------------------------


Hi,
a quick solution might be something along these lines.
I don't think this kind of replacement is needed very often, hence it is a
rather dirty ad hoc script with hardcoded search and replacement text. - These
should be modified to the specific needs. To use the same array repeatedly from
the beginning, the script must be recompiled - menu Scripts.

The script file should be saved e.g. as
...[PSPadFolder]\Script\JScript\seq_replace.js

after recompiling the scripts in the menu, a new item should be there to call
the function (supposing the scripting support is enabled in pspad Settings::
System integration :: Integrated scripting support - WSH)


hth,
 vbr

cite:
--------------------------------------------------------------------------------
/*
a quick and dirty script to replace a given pattern (regular expression) with a
(hardcoded) sequence of strings stored in an array
after exhausting the array the script must be recompiled to activate it again
(PSPad menu - Scripts >> Recompile) 
*/


var module_name = "seq_replace";
var module_ver = "0.0.1";  

// fill in the list of replacement strings - linebreak - "\n"
var listOfReplacements = new Array("First line to insert.\n", "Second line to
insert.\n", "Third line to insert.\n", "Forth line to insert.\n", "Fifth line to
insert.\n");

// modify the pattern between /.../ (it is a regular expression), "
" denotes
a line-break here
var patternToReplace = new RegExp(/replaceme
/g);

function replaceSeq(){
if (editorsCount()<1){return;}
var actEd = newEditor();
actEd.assignActiveEditor();

var inputTxt = actEd.text();
var outputText = inputTxt.replace(patternToReplace, function($0){if
(listOfReplacements.length > 0){return listOfReplacements.shift();}else{return
$0;}});
actEd.text(outputText);
}

function Init(){
addMenuItem("replace sequentially", "", "replaceSeq","");// labels and shortcuts
can be modified
}


--------------------------------------------------------------------------------


-- 
<http://forum.pspad.com/read.php?2,47351,47354>
PSPad freeware editor http://www.pspad.com

Odpovedet emailem