You don't have access to the found string parts referenced by $1 and $2. This replacement happens deeply inside the Perl regular expression function. If you want parts of the found string written to output window, you need to evaluate the found string by yourself in the script and then make the replace. This can be done by following code in your case:
- Code: Select all
var sFound= '(</end><first><second id=".*?"><note>)([\\s\\S?]+?<para>)';
// var sReplacedNote= '$1<para level="4" change="add" rfc="statement">' + sReplaced+ '</para>$2';
if (sFirstStep){
UltraEdit.activeDocument.top();
if (UltraEdit.activeDocument.findReplace.find(sFound))
{
var sReplacedNote = UltraEdit.activeDocument.selection.replace(/<note>/,"<note><para level=\"4\" change=\"add\" rfc=\"statement\">" + sReplaced + "</para>");
UltraEdit.activeDocument.write(sReplacedNote);
}
}
So the Replace command is replaced by a Find command. If a string is found, it is selected. This selected string is taken and converted now within the script into the replace string you want.
sReplacedNote contains then the string which can be written to output window and which is written into the file overwritting the found string.
A few more notes:
The character
/ (forward slash) has no special meaning in regular expressions. Therefore it is not necessary to escape
/ with a backslash as you have done at beginning of the search string.
{1} in a Perl regular expression means the previous character or expression exactly 1 times. I don't see any reason for
{1} after character
d of the word
second. If you omit
{1} you specify that next character after
second must be a space character and therefore
secondd would be automatically ignored like when using
{1}.