-
1. Re: GREP Find Change with Positive Lookahead not working
Tom Usrey Oct 23, 2009 6:45 AM (in response to mattaca)You'll probably have better luck asking this in the InDesign Scripting Forum.
-
2. Re: GREP Find Change with Positive Lookahead not working
pkahrel Oct 23, 2009 8:33 AM (in response to mattaca)> I realized after posting this that lookaheads and lookbehinds are supposed to be fixed-length
That goes for lookbehinds. Lookaheads can deal with variable-length matches.
You GREP -- (?i)(?s)^.(?=.+END TOC) -- says: "Match the first character of the story": ^. is the first character of the story, (?=.+END TOC) matches everything after the first character up to and including END TOC.
What exactly are your trying to achieve?
Peter
-
3. Re: GREP Find Change with Positive Lookahead not working
mattaca Oct 23, 2009 11:58 AM (in response to pkahrel)Thanks for the info about positive lookaheads being able to handle variable lengths, Peter. I realized my example using ^. should actually have used ^\w. Sorry about that. That still doesn't solve the initial problem though. Let me see if I can explain better.
The TOCs in our cookbooks have main recipes and they also have variations. What I'm trying to do is to style ALL of them via GREP Find/Change.
The attached image has three examples. The left is how the text comes to me, with all paragraphs set as Body - text indent. The middle is how it looks if I style the variations first, via the find change below. This searches for any paragraph in the document starting with a tab, before the words END TOC. Works great.
Find What: (?i)(?s)^\t(?=.+END TOC)
Change To:
Find Format: Paragraph Style = Body - text indent (this is applied to all paragraphs when I place the document)
Change Format: Paragraph Style = TOC - Recipe Variation
The right image is how it looks if I style the main entries first, via the find change below. It searches for any paragraph starting wtih a word character, before the words END TOC. Also works great.
Find What: (?i)(?s)^\w(?=.+END TOC) (^\w works, whereas ^. didn't)
Change To:
Find Format: Paragraph Style = Body - text indent
Change Format: Paragraph Style = TOC - Recipe
The problem is, no matter which find/change I do first, IT THEN CAN'T DO THE OTHER. My questions are:
1) does having multiple paragraph styles applied prevent GREP from being able to use Single-line Mode (?s)?
and 2) is there a way around it?
I hope this makes sense.
Matthew
-
Picture 1.png 205.0 K
-
-
4. Re: GREP Find Change with Positive Lookahead not working
pkahrel Oct 24, 2009 2:35 AM (in response to mattaca)The problem is that the second query cancels the first one, no matter the order in which you apply them. This should work though:
Find What: (?i)(?s)^.+(?=END TOC)
Change To:
Find Format: Paragraph Style = Body - text indent
Change Format: Paragraph Style = TOC - Recipe
Now all paragraphs up to END TOC are in "TOC - Recipe". The next step is to apply "TOC - Recipe Variation" to the paragraphs styled "TOC - Recipe" AND which start with a tab:
Find What: ^\t
Change To:
Find Format: Paragraph Style = TOC - Recipe
Change Format: Paragraph Style = TOC - Recipe Variation
Does that work for you?
Peter
-
5. Re: GREP Find Change with Positive Lookahead not working
mattaca Oct 26, 2009 7:11 AM (in response to pkahrel)Brilliant! That worked perfectly! Very clever solution—wish I had thought of it.
Thank you Peter!
Matt


