Wouldn't it make sense to use an ordinary nested style through 3 words?
BUT, for GREP, perhaps ^.+?\>.+?\<.+?\>.+?\<.+?\> Seems to work with or without punctuation between words.
It's not exactly what I say! I don't want to find the 3 first words. I only want to find all the para words except the 3 first ones!
Maybe my english is no correct!
So, in the para: My tailor is rich!
I want to find: rich!
Not: My tailor is
Sorry, my mistake -- I read it incorrectly. I would definitely use a nested style for this, not GREP, since that can count words.
Nested style not accepted. Only grep style (if possible). I'll explain you later.
Why? If you are doing something to the entire paragraph except the first three words, you should really be formatting the paragraph that way, then applying a style to the first three.
But how about doing whatever it is you want the entire paragraph with one GREP style, then reverse it for the first three words with a second?
I make tests with "Power Headers"", barbs/in-tools.com's plug-in!
As you know, it's a very powerful tool to manage headers! It's easy to find the 3(2,3,4,5,6,...) last words of a page and insert them as header.
But I can't find the way to do it with the beginning of the page!
That's the reason of my question! I've another solution to do it (with another [JS] ; I'll tell later what it is!).
So, What I need in this approach, it's a grep code to catch it!
Now I think your logic is backwards. For the beginning of the page you would want the first three words, not to exclude them, in the header, and for the end of the page you would want the last three words, which you already know how to find.
Apparently, Gabe Harbs thinks differently: What we find is excluded! So, in a para with 5 words, what we have to find is not the 3 first words (what we finally want) but the 4th and 5th words!
Unless you miss the problem, the grep code is anyway interesting to discover!
I've never used Power Headers, so I wouldn't know, but the GREP I posted above will find the first three words, and a similar expression can be used to find the last three -- but GREP works on a paragraph level -- not the page level, so I don't know how useful a GREP style would be, anyway. How do you assigne the correct paragraph styles to the first and last paragraphs on the page? How do you want to handle paragraphs that break across pages?
Not sure I'm following what you are doing, but this script will get the text from word 4 to the end of the selected text frame (you could loop through the document's frames). What do you want to do with the text when you get it?
tell application "Adobe InDesign CS6"
--a selected text frame
set s to object reference of text of selection
set x to index of first character of word 4 of text of selection as integer
set y to index of last character of text of selection as integer
--text from the 4th word to last character of the frame
set t to text from character x to character y of item 1 of s
Power Headers is "amazing". It can manage a story page per page.
So, if a para begins at the bottom of a page and finishes at the top of the following, it works as we have "two" paras!
If I tell it (to the plug-in) that I only want the first instance it finds, the deal is OK!
So here my problem is to find all the words of the first para of a page (left page) except the 3 first ones. For the right page, find the 3 last words of the page, even if the last para of this page goes on the following one.
[the grep code I use in this case (right page) to do this is: (.+)\s(?=\S+\s\S+\s\S+)
It gives me the entire para except the 3 last words I finally want!
Power Headers is an amazing plug-in written by Gabe Harbs (in-tools.com). It does a lot of things about headers that ID can't do.
What I want to do here is catching in a header (on the left page) the 3 first words of the left page and in another header (on the right page), the 3 last words of the right page.
I don't want to use anything else than Power Headers. For this, I only need a grep code to allows me to finish the job with it.
In fact, what I apparently need is a grep code to find what I don't want to keep! What the grep code don't find … is what I finally want!
To really understand, you need to take a look to Power Headers!
[I've already find a solution for the left page but it sounds like real amateurism even it works!]
Sorry for my late response here. (I missed your PM as well.)
To get the whole paragraph minus the first three words, you can do something like this:
Basically, it splits the paragraph into two groups and drops the first one.
You can use a similar strategy to get some text in the middle of the paragraph, or to drop text in the middle, etc.