RegExp search and replace, keep original text formatting
Hello!
Required to make search and replace in a text frame using RegExp.
And at that keep original character formatting of the text frame.
How it's possible?
Bad example – it changes the formating of the entire text to the format of the first character:
var reg = /a/gmi;
var replacer = '*';
var fr = activeDocument.textFrames[0];
fr.contents = fr.contents.replace (reg , replacer);

Thanks!
