I've been asked to re-post this InDesign GREP question here under scripting...
I do not know GREP well enough to begin to tackle this. And as usual, I'm in a pinch!
Also, if you're the visual type, just look at the second to the last paragraph at the bottom, and that may be enough to help you devise the GREP style. Otherwise, bear with me, I have to think this through...
I have a list that spans pages of events. The events are formatted as follows:
☐Box City EventNameSpecific Month EndPara (this is a single paragraph in a story of a hundred such paragraphs)
On paper, each event will need to be preceded with a filled specific-colored box (☐). I would like this box to be made from a strikethrough applied to an em space using grep, since that is very easy to create using a character style and only requres one setting (the thickness of the strikethrough).
There is a legend at the bottom of the page, detailing about 14 types of events. Some of the different types of events will require the same colored box. But in all I have 7 different colors of boxes in the legend.
I'm looking to create...
- 7 character styles, one for each color (consider this done already)
- 1 paragraph style (essentially done, but missing the GREP)
- 7 GREP styles (or more as necessary) specifically to apply only to the em space that precede specific sets of text strings
- If I need, or if it is simpler to create 14 GREP styles within the paragraph style, that's fine. But I understand we may be able to do something like this... (Target phrase 1 | Target phrase 2 | Target phrase 3) in between parenthesis to identify multiple possible triggers within the same rule.
- I'm fine whether it's 7 or 14 rules in there, I just want to be able to update them over the course of time as necessary - but it won't be for another season at least if I do.
I don't know GREP well enough to piece together what I need. Vaguely familiar with look aheads and look behinds. I do understand it may be easier if the em space is in between other characters, so in my example below I've inserted hairspaces. But ultimately I want the em space to be flush or nearly flush to the left of the frame. For my example below:
- I only want to apply character styles to em dashes based on the strings in bold.
- The strings of text that will trigger the GREP will vary in number of words and may or may not contain a dash.
- I want to ignore Citynames regardless of number of words... Chicago vs. San Francisco vs. Vancouver, BC for example.
- I want to ignore MonthofYear which appears after the second tab.
- The tabs will have set stops as a regular part of the paragraph style. I'm including them in my example below in case it helps to visualize possible anchors to use in GREP.
- I want the style to be easy enough to modify, for example if I want to simply add an (EEEE New Eventname) to the list of possible options within a rule that triggers a specific character style. See below should make it clearer.
So here's what I'm thinking...Within the Paragraph Style, the first two examples of GREP Styles should be able to respond to the following criteria: Rule 1: If the paragraph contains any of the following, then apply Char Style 1 to the em dashes in those paragraphs. Use a unique GREP expression for each phrase below where each uses Char Style 1 or use a single GREP expression to capture all three possible triggers:
- ABC BB Invitational
- ABC Xxxxxxxxxxxxxx
- ABC MM-Xxxxxxxxxxxxxxx
Rule 2: If the paragraph contains any of the following, then apply Char Style 2 … and so on
- Global ABC Xxxxxxxxxxxxxxx
- Global WXYZ Xxxxxxxxxxxxxxx
I cannot count on “ABC” or “Global” being the trigger for the style, if you know what I mean. I need the entire phrase (ABC BB Invitational) to be the trigger… if it exist in its entirety, then apply the style to the preceding em dash in that paragraph. This way if there are any mispellings or if we launch a new event type which ends up flowing in to my document I will know it.
hairspace emspace tabspace CitynameOneWord ABC BB Invitational tabspace MonthofYear
hairspace emspace tabspace Cityname TwoWrds ABC BB Invitational tabspace MonthofYear
hairspace emspace tabspace Cityname MultiWrds ABC BB Invitational tabspace MonthofYear
hairspace emspace tabspace Cityname TwoWrds ABC MM-Xxxxxxxxxxxxxx tabspace MonthofYear
hairspace emspace tabspace Cityname MultiWrds ABC Xxxxxxxxxxxxxx tabspace MonthofYear
hairspace emspace tabspace Cityname TwoWrds Global ABC Xxxxxxxxxxxxxxx tabspace MonthofYear
hairspace emspace tabspace CitynameOneWord Global WXYZ Xxxxxxxxxxxxxxx tabspace MonthofYear
hairspace emspace tabspace CitynameOneWord Global Special Xxxxxxxxxxxxxxx tabspace MonthofYear
hairspace emspace tabspace CitynameOneWord Globl Special WRONG SPELLING tabspace MonthofYear
I hope this makes sense and isn't too unnecessarily redundant. Time for bed. Fingers crossed someone will post at least one GREP string, so I have some magic code for tomorrow morning! Ideally, it would be great if you would include a brief explanation of waht the string is doing, but minimally, please do use one of my text stings above, so I know what to mess with and what not to. ;-)