Mofi, thank you. I've been trying this out. In RB (RegexBuddy) it works perfectly well. The trouble is that when I insert it into my UE script it doesn't work. RB provides different options: a copy 'as is', or as a 'perl-style' string:
'as is':
Code: Select all
<\$F((?:[\s\S]+?))>(?<!<>)(?<!< >)(?<!< >)(?<!<I>)(?<!<I\*>)(?<!<CR>)(?<!<N>)(?<!<->)
'perl-style':
Code: Select all
'<\$F((?:[\s\S]+?))>(?<!<>)(?<!< >)(?<!< >)(?<!<I>)(?<!<I\*>)(?<!<CR>)(?<!<N>)(?<!<->)'
The same for the 'replace' string:
'as is':
perl-style:
The trouble is that whatever I do, I can't get my script to work. Have I got the find/replace line wrong?
Code: Select all
if (UltraEdit.document.length > 0) {
UltraEdit.insertMode();
UltraEdit.columnModeOff();
UltraEdit.activeDocument.hexOff();
//UltraEdit.ueReOn(); // UltraEdit
//UltraEdit.unixReOn(); // Unix
UltraEdit.perlReOn(); // Perl
UltraEdit.activeDocument.top();
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=true;
////////// formatting commands
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.replace(" << ","<<");
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.replace(" >>",">>");
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.replace("<<","<$F");
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.replace(">>","[]>");
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.replace("@N = ","@n=");
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.replace("@EN = ","@en=");
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.replace("@n=","@NOTE = ");
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.replace("@en=","@ENDNOTE = ");
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.replace("@h3=","@HEAD3 = ");
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.replace("@h4=","@HEAD4 = ");
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.replace("@h5=","@HEAD5 = ");
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.replace(" "," ");
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.replace("open italics","<I>");
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.replace("close italics","<I\*>");
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.replace("<I> ","<I>");
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.replace("open bracket","(");
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.replace("close bracket",")");
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.replace("open quote","\"");
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.replace("close quote","\"");
UltraEdit.activeDocument.top();
// Replace <$F....> with <<....>>
UltraEdit.activeDocument.findReplace.replace("<\$F((?:[\s\S]+?))>(?<!<>)(?<!< >)(?<!< >)(?<!<I>)(?<!<I\*>)(?<!<CR>)(?<!<N>)(?<!<->)","<<${1}>>");
UltraEdit.activeDocument.top();
} // <---END OF "IF" IN LINE 1! (DON'T DELETE)
The 'sand-box' text that I use is this:
Code: Select all
Back-references 1 contains the full FN, without the '<$F' and the '>'.
The negative lookbehind (creating back-reference 2) is there to discard the
<>, < >, < >, <->, <I>, <I*>, <N>, <CR>
this is text this is text this is text<$Fendnote endnote endnote>
this is text this is text this is text this is text this is text
this is<$Fendnote must span new line plus blanks lines
endnote> text this is text this is text
this is text<$Fendnote <>This is a <I>title<I*> and this is another <I>Title
<I*>
endnote<N> end<->note> this is text this is text
this is text this is text this is text this is text
this is text this is text this is
text this is text this is text this is text this is text this is text<$Fendnote endnote <CR>
endnote> this is text this is text this is text this is text t
his is text this is<$Fendnote <N> <I>title <I*>end<->note <>endnote> text this is text this is
text this is text<$Fendnote <CR>
endnote endnote> this is text this is text this is text this is
text this is text this is text this is text this is text this is text this is text
this is text this is text this is text this
best,
fvg