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...
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:
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:
Rule 2: If the paragraph contains any of the following, then apply Char Style 2 … and so on
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. ;-)
Well, for a moment I thought I had an idea of how to do this with GREP styles, but I realized it wouldn't work, and I'm not sure it's possible unless you are able to make a separate style for every possible string between the em space and the trigger text. You want to use the lookahead because you want to find that text, but you don't want to select it or apply the style to it, but a lookahead can't handle the kind of variability on string length that you need to work based on just the bolded text at the end.
It would actually be easier to use paragraph styles based on the bolded text that include a nested character style, I think. That could be handled by find change, but I think the best thing is probably to move this over to scripting.
Rather than just move the discussion, though, I'm going to ask you to cross post so there are two threads on the chance that someone else who doens't visit scripting might have another idea for you here.
Here's a link to scripting: InDesign Scripting
Someone did respond quickly with a GREP code sequence that essentially worked with a little tweaking. I'm posting the link to it here in case it helps someone else: http://forums.adobe.com/message/4980597#4980597