myResults.paragraphs.index is an index of current paragraph's start (1st character).
So comparing this with myResults.index gives you a difference of position,
Looking for anchored object could start with catching myResults.paragraphs.allPageItems
If there is any you could still compare indexes. Index of anchored item is:
(assuming there is one)
@John – I think, the second question contradicts the first question a bit.
If an anchored object is present just before "TO", "TO" cannot be the first two characters in the paragraph.
an anchored object is a valid character object in a texts object.
With a GREP search you are able to single out all combinations of Anchored Objects with "TO" that are or are not at the beginning of a paragraph.
That said, I'm not sure at all what you exactly trying to do here…
In GREP search:
^ represents the beginning of a paragraph
~a represents an anchored object
So the following expression is using a positive Lookbehind
and will find all instances of "TO" preceded by an anchored object at the beginning of a paragraph.
And the following GREP expression
will find all instances of "TO" at the beginning of a paragraph (no anchored object present!)
In code the first example will mean:
app.findGrepPreferences = app.changeGrepPreferences = null; app.findGrepPreferences.findWhat = "(?<=^~a)TO"; myResultTextsArray = app.documents.findGrep();
Many thanks for your feedback. It works great...
Many thanks for your helpfull info...