I'm completely new to GREP. I will try to learn it over time, but for now I wonder if someone could give me a hand.
I have many paragraphs like this:
5/28/11 (Sat) Duke’s Epic 8 Hour Series, Opus Spring Relay. A fun filled day for the whole family! Mansfield Outdoor Centre, Mansfield, ON. www.chicoracing.com
6/04/11 (Sat) - 6/05/11 (Sun) Trek Store Canada Cup/Ontario Cup. Canada’s longest running and largest National MTB event. Ontario Cup, Canada Cup, and UCI Cross Country event. See the pros and race for fun! Hardwood Ski and Bike, Barrie, ON. www.trekstorecanadacup.ca
Basically I want to apply a style to the dates which are on the first line of each paragraph. So, the pseudo code would be something like: select all characters from the start of each paragraph to the last instance of ")", and apply a style.
I want to apply a character style to make the dates bold such as this:
5/28/11 (Sat) Duke’s Epic 8 Hour Series, Opus Spring Relay. A fun filled day for the whole family! Mansfield Outdoor Centre, Mansfield, ON. www.chicoracing.com
6/04/11 (Sat) - 6/05/11 (Sun) Trek Store Canada Cup/Ontario Cup. Canada’s longest running and largest National MTB event. Ontario Cup, Canada Cup, and UCI Cross Country event. See the pros and race for fun! Hardwood Ski and Bike, Barrie, ON. www.trekstorecanadacup.ca
Thanks!
Ak
Warning! I'm not an expert in GREP -- other guys on this forum may suggest a better solution.
Find what:
(\d{1,2}/\d{1,2}/\d{1,2}\s\((Sun|Mon|Tue|Wed|Thu|Fri|Sat)\))(\s-\s\d{1,2}/\d{1,2}/\d{1,2}\s\((Sun|Mon|Tue|Wed|Thu|Fri|Sat)\))?
Change Format: + Bold
P.S. If you are going to use this in script, you have to escape backslashes:
"(\\d{1,2}/\\d{1,2}/\\d{1,2}\\s\\((Sun|Mon|Tue|Wed|Thu|Fri|Sat)\\))(\\s-\\s\\d{1,2}/\\d{1,2}/\\d{1,2}\\s\\((Sun|Mon|Tue|Wed|Thu|Fri|Sat)\\))?"
Very interesting. I tried Haakenlid's version and it does work, but not in all cases. Since some of the listings have a parenthese in the body (not just the date) it will select up to the last parenthesis in the paragraph (like Mary said).
Also, some of my listings have some A-Z characters in front of the dates, which this method skips.
Thanks for the other option though, it's good know!
Ak
It will not trigger on numbered lists if you InDesigns built-in list styles, which I kinda assumed everyone uses.
My expression does what was asked for in the original post, but with the addition of only looking for paragraphs that starts with a digit.
select all characters from the start of each paragraph to the last instance of ")", and apply a style.
Here's another expression that is much more strict, while still not too long. Short regular expressions are much easier to debug and modify.
((\d+/?)+ \(\w+\)( - )?)+
Or this (even stricter, will not accept "Monday" instead of "Mon" or "6/04/2011" instead of "6/04/11"):
((\d{1,2}/?){3} \(\w{3}\)( - )?){1,2}
North America
Europe, Middle East and Africa
Asia Pacific