Thanks Jongware! … 3 lines seem to be enough!
app.findTextPreferences.findWhat = "a"; app.changeTextPreferences.changeTo = "b"; app.selection.changeText( );
Heh heh – No, that's exactly what I did (!), but my 1st line is "app.findGrepPreferences = app.changeGrepPreferences = null;". If you omit that, you could be nastily surprised if there were a couple of previous settings in the dialog. (Does this mean that you were able to answer your own question? I think you did.)
So, safest is to forget 'contents' exists and stick to InDesign's 'formatted text' objects such as 'story', 'paragraph', and 'texts' itself. 'contents' has its uses but only if you are inserting new text, or re-purposing text for use 'outside' your document.
Nice to see you're getting along in scripting, by the way!
Yeap! I found this approach later!
I'm working a lot on [JS] for a while and we're lucky to have here very great and nice Masters!