Reputation: 11
Inside an UltraEdit script I've got a bit of code like so:
var FNstring = UltraEdit.activeDocument.selection;
var FNstring = UltraEdit.activeDocument.selection.replace(">>","</p>");
var FNstring = UltraEdit.activeDocument.selection.replace("\r\n","<BR>");
A var_dump confirms that the content of the string at this moment is:
text text text
text text text text text text text text text
text text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text text
text text text text text text text text text
text text text text text text text text text
text text text text text text>>
I'm just not getting those find/replace commands right:
Replace the >>
with (/p)
(once only)
Replace all CR
/LF
with (br)
. (0 or >1 )
That code above is just not doing it. I'm getting something wrong. How can I fix this?
Upvotes: 1
Views: 623
Reputation: 49097
Those three lines of code do the following:
>>
by </p>
in the created copy.\r\n
by <BR>
in the created copy.That is not what you want. The replace function of the JavaScript String object has nothing to do with the replace function of the UltraEdit document object.
You could use instead following two lines:
var FNstring = UltraEdit.activeDocument.selection.replace(/>>/g,"</p>");
UltraEdit.activeDocument.write(FNstring.replace(/\r\n|\n|\r/g,"<BR>"));
Those two lines do following:
FNstring
with replacing all occurrences of >>
by </p>
in the created copy.FNstring
with replacing all occurrences of a DOS (Windows) or UNIX or Mac line termination by <BR>
and write this new string over the selection in the active document of UltraEdit.Upvotes: 1