How to get the word after searching for a character with Javascript?
Hello,
I want to search for a specific letter like "ñ" in InDesign using Javascript. findText is the fastest way than using indexOf.
But how can I then determine the word like "señior" in which the letter occurs?
.constructor.name tells me I have found a character.
.parent returns "story" as a result and not the word in which the character is contained.
How can I determine the word from the search result?
My (simplified) Javascript looks like this:
// Find a character and get the word
var myDocument = app.activeDocument;
app.findTextPreferences.findWhat = "ñ";
var myFoundItems = myDocument.findText();
alert(myFoundItems[0].constructor.name);
alert(myFoundItems[0].parent);