No answers here so far, and finally I made one by myself (for the active tab only).
The script for several consecutive regex find/replace actions with the find/replace pairs predefined within the script.
Version A (line-by-line style):
Code: Select all
// predefined regex find replace line-by-line style
var hMainWnd=AkelPad.GetMainWnd();
if (hMainWnd)
{
nSelStart=AkelPad.GetSelStart();
nSelEnd=AkelPad.GetSelEnd();
if (nSelStart == nSelEnd)
AkelPad.SetSel(0,-1);
pSelText=AkelPad.GetSelText();
pSelText=pSelText.replace(/AAA/g,"BBB");
pSelText=pSelText.replace(/CCC/g,"DDD");
pSelText=pSelText.replace(/EEE/g,"FFF");
pSelText=pSelText.replace(/(\d{2})-(\d{2})-(\d{4})/g,"$3-$2-$1");
AkelPad.ReplaceSel(pSelText);
AkelPad.SetSel(nSelStart,nSelStart);
}
Version B (hash-table style):
Code: Select all
// predefined regex find replace hash-table style
var hMainWnd=AkelPad.GetMainWnd();
if (hMainWnd)
{
nSelStart=AkelPad.GetSelStart();
nSelEnd=AkelPad.GetSelEnd();
if (nSelStart == nSelEnd)
AkelPad.SetSel(0,-1);
pSelText=AkelPad.GetSelText();
var hashTable = {
"AAA":"BBB",
"CCC":"DDD",
"EEE":"FFF",
"(\\d{2})-(\\d{2})-(\\d{4})":"$3-$2-$1"
};
for(var hashKey in hashTable)
pSelText=pSelText.replace(new RegExp(hashKey,"g"),hashTable[hashKey]);
AkelPad.ReplaceSel(pSelText);
AkelPad.SetSel(nSelStart,nSelStart);
}
Text to check how the example script works:
Code: Select all
AAA = BBB
CCC = DDD
EEE = FFF
05-09-2024