Skip navigation
smashkirk
Currently Being Moderated

GREP advice

Jan 11, 2011 8:42 AM

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

 

 
Replies
  • Currently Being Moderated
    Jan 11, 2011 10:06 AM   in reply to smashkirk

    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)\\))?"
    
     
    |
    Mark as:
  • Currently Being Moderated
    Jan 11, 2011 3:09 PM   in reply to smashkirk

    If you're using CS4 or CS5 and this is a routine job, you may want to set this up as a GREP style.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 12, 2011 7:54 AM   in reply to Kasyan Servetsky

    That's a bit overkill.

    This will work as well:

     

    
    ^\d.*\)
    
     
    |
    Mark as:
  • Currently Being Moderated
    Jan 12, 2011 8:00 AM   in reply to Haakenlid

    Only if you are absolutely certain the following text doesn't contain parentheses -- or any numbered list at all

     

    Kasyan is downplaying his GREP-fu, but he's spot on -- his version will work exclusively and only on the given date or dates.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 12, 2011 8:08 AM   in reply to [Jongware]-9BC6tI

    Thanks, JW, I was just about to post that! The shorter search string works on the supplied text, but it's "greedy" -- it'll apply bolding up to the LAST close-parenthesis in the paragraph.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 12, 2011 8:26 AM   in reply to smashkirk

    Do you have a sample of a listing with A-Z characters before the date? When they do appear, is it a consistent/predictable pattern?

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 12, 2011 8:44 AM   in reply to [Jongware]-9BC6tI

    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}
    
     
    |
    Mark as:
  • Currently Being Moderated
    Jan 13, 2011 2:34 AM   in reply to smashkirk

    paste the below expression in indesign Find/change Grep

     

    Try this expression,

     

    (\d{1,2}/?)+ \(\w{3}\)
    

     

    the above will not include the hyphen, do u really want to add it? if you want to include try the below one

    ((\d{1,2}/?)+ \(\w{3}\)( - )?)+
    
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points