6 Replies Latest reply on Aug 9, 2012 6:08 AM by Trevorׅ

    Finding only the words at a selection point


      I am beginning to put together a javascript that will enable me to place words in the document dictionary and am struggling to understand the relationship between InDesign Object Word and the words method and how else I might find only the words within a text object at the selection level.


      Select "grapes"  run

      app.selection.constructor.name returns  "Word"

      app.selection.contents returns "grapes"


      Select "grapes,"

      app.selection.constructor.name returns "Text"

      app.selection.words[1].contents returns "grapes," not grapes.


      Any punctuation that is attached to a word in a selection other than whitespace appears to be considered to be part of the word in the words collection.


      Short of resorting to regex, is there away to return only the word?