Skip to main content
Participant
February 21, 2024
Question

Using GREP

  • February 21, 2024
  • 2 replies
  • 182 views
GREP Question...
 
I have a client that provided me addresses like this:
First Last Name 1234 This Road, City, State Zip
or First Last Name 1234 This Road, City City, State Zip
 
During the proofing process they have asked that anywhere the Zip ends up on a line by itself, they would like it to be:
First Last Name 1234 This Road
City, State Zip
or City City, State Zip
 
(City City is for example Los Angeles or San Francisco)
 
Clearly this would be a massive pain to fix manually. Can GREP fix this?
 
I tried a GREP code that I found to fix just the Zip Runt, but it ends up messing something up somewhere because it ends up bumping to overset text for 50 pages.
 
And then realized they actually want the whole City, State Zip bumped. They technically asked for just the instances where there is the Zip runt, but I'm totally open to telling them I have to bump it for all.
 
Gah. I hope this all makes sense. Thanks. 🙃
This topic has been closed for replies.

2 replies

Robert at ID-Tasker
Legend
February 21, 2024

Are "," ALWAYS there?

 

Is it a long list or single instances? 

 

If a single long list - you could play with a table. 

 

Or GREP that will skip first "," and apply CharStyle with NoBreak to the rest would do the job.

 

m1b
Community Expert
Community Expert
February 21, 2024

Hi @youthful_Rainbow1674, this article might help, specifically the section on runts. The idea is to use a grep style in your body paragraph style that identifies *any* runts by accessing the last two words of a paragraph and applying the no-break attribute via a character style. This might be good in your situation. Their trick of adding a space at end of paragraph to override the grep style seems clever.

 

Otherwise you could use a grep that targets the State two-letter code and zip code specifically, eg "CA 94043":

([A-Z]{2})\s+(\d{5}(-\d{4})?)\.?$

- Mark