UltraEdit 2022.1.0.100 64-bit
I'm rewriting some code that Mofi helped me with many years ago. (Really delighted that's he's still helping us novices along. Great!)
!´ve got used to testing all my regex code in RegexBuddy nowadays - it's a real help, I use it regularly. I can thoroughly recommend it. (Except: it has no converter for the UE flavor.)
The following regex works just fine in RegexBuddy:
RegexBuddy (latest version) set for "Perl 5.30-532")
FIND STRING:
REPLACE STRING:
Using the "convert to java string" converter inside RegexBuddy hence produces:
In RegexBuddy this regex works just fine. Here's what it does. It takes a text like the one below and does the following: it replaces the footnote placeholders in the main text (marked by <<--x-->> ) with the footnotes in the footnote block, at the end of the text, which start with "[x] footnote footnote<CR>" But if I put this regex inside this UE script (which I think Mofi once wrote for me) it doesn't work.
What am I doing wrong?
(Once this regex is up and running, I will want to put it inside that "WHILE" loop, so that it iterates through all of the place markers in the text "<<--x-->>") (Which means my next problem is: how to turn that "1" into a variable.)
(If it's not too expensive I'd be quite happy to join the VIP+ club.)
Very best, and most grateful for help ...
I'm rewriting some code that Mofi helped me with many years ago. (Really delighted that's he's still helping us novices along. Great!)
!´ve got used to testing all my regex code in RegexBuddy nowadays - it's a real help, I use it regularly. I can thoroughly recommend it. (Except: it has no converter for the UE flavor.)
The following regex works just fine in RegexBuddy:
RegexBuddy (latest version) set for "Perl 5.30-532")
FIND STRING:
Code: Select all
(?P<FNplaceholder><<--1)-->>(?P<mainText>\p{Any}*?)(?P<footnote>\[1*\N.*)
Code: Select all
$+{FNplaceholder}$+{footnote}>>$+{mainText}
Code: Select all
"(?P<FNplaceholder><<--1)-->>(?P<mainText>\\p{Any}*?)(?P<footnote>\\[1*\\N.*)","$+{FNplaceholder}$+{footnote}>>$+{mainText}"
What am I doing wrong?
(Once this regex is up and running, I will want to put it inside that "WHILE" loop, so that it iterates through all of the place markers in the text "<<--x-->>") (Which means my next problem is: how to turn that "1" into a variable.)
(If it's not too expensive I'd be quite happy to join the VIP+ club.)
Very best, and most grateful for help ...
Code: Select all
if (UltraEdit.document.length > 0)
{
UltraEdit.insertMode();
UltraEdit.columnModeOff();
UltraEdit.activeDocument.hexOff();
UltraEdit.perlReOn(); // Regex Perl
UltraEdit.activeDocument.findReplace.mode=0;
UltraEdit.activeDocument.findReplace.matchCase=true;
UltraEdit.activeDocument.findReplace.matchWord=false;
UltraEdit.activeDocument.findReplace.regExp=true;
UltraEdit.activeDocument.findReplace.searchDown=true;
UltraEdit.activeDocument.findReplace.searchInColumn=false;
UltraEdit.activeDocument.findReplace.preserveCase=false;
UltraEdit.activeDocument.findReplace.replaceInAllOpen=false;
UltraEdit.activeDocument.findReplace.replaceAll=false;
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.replace("(?P<FNplaceholder><<--1)-->>(?P<mainText>\\p{Any}*?)(?P<footnote>\\[1*\\N.*)","$+{FNplaceholder}$+{footnote}>>$+{mainText}");
while(UltraEdit.activeDocument.findReplace.find("TheresSomethingToFind")) //<------semicolon yes or no?
{ // start loop -----------------
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.replace("a","1");
} // <-----------end loop --------
/////////////////////////////////////////////////////////////////////////////////////////////
} // <---END
// EOF
Code: Select all
text text text texttext text text<<--1-->> text text text text text text text text text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text texttext text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext texttext text text text text<<--2-->> text text text text text text text text text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttextexttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text tex<<--3-->> t text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text text
text text text text text<<--4-->> text text text text text text text text text text text text text texttext text text text text text texttext ext text text text text texttext text text text text text texttext tex
text textt text text text texttext text text text text<<--5-->> text text text text text text text text text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text textext text text text texttext text text textext text text text text text texttext text text text text text text
text text text text text<<--6-->> text text text text text text text text text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text text text text text text text<<--7-->> text text text text text text text text text text text text text texttext text text text text text texttext text text text text text texttext text text texxt text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text text
text text text text text<<--8-->> text text text text text text text text text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text textext text text text text text texttext text text text text text text
text text text text text<<--9-->> text text text text text text text text text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text texxttext text text text text text texttext text text text text<<--10-->> text text text text xt texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text<<--11-->> text text text text text text text text text text text text text texttext text text text text text texttext text text t text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text text texttext text text text text<<--12-->> text text text text text text text text text text text text text texttext text text text text text texttext text text text text text texttext text text text text text text
[1] footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote foote footnote footnote footnote footnote footnote footnote footnote footnote foofootnote footnote footnote
[2] footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote
[3] footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote
[4] footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote
[5] footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote
[6] footnote footnote footnote footnote footnote tnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote
[7] footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote
[8] footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote fofootnote footnote
[9] footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote
[10] footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote
[11] footnote footnote foootnote footnote footnote footnote footnote footnote footnote
[12] footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote footnote