I found such a script. But it works on all open files and takes a lot of time. How do I do it to only one current tab.
var doc = activeDocument;
for(var i = 0; i < app.documents.length; i++)
for(var j = 0; j < app.documents[i].textFrames.length; j++){
var str = app.documents[i].textFrames[j].contents;
var rep = str.replace ("PANTONE", "P.");
app.documents[i].textFrames[j].contents = rep;
}
redraw();