• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

GREP query applying new paragraph style

New Here ,
Apr 30, 2023 Apr 30, 2023

Copy link to clipboard

Copied

Hello all,

This is probably a very simple GREP request, but I can't seem to figure out how to make it work. I am trying to apply a bolded paragraph style to a directory in which the first paragraph is the business name, followed by additional paragraphs which are the personal contact, address, phone number and website followed by an empty paragraph return and then another business name, personal contact, address, etc. as shown below.

 

Business name

Personal contact

Address

Phone number

Website

 

Business name

Personal contact

Address

Phone number

Website

 

I have tried to apply a GREP find/change where it finds two paragraph returns with format A and then have the change be to two paragraph returns with format B (the bolded style). This results in InDesign changing the format of the original paragraph (the website) at the beginning of the find/change and not the paragraph at the end (the business name). I can't seem to figure out how to change the forward paragraph/text line and not also change the first paragraph/text line.

 

Any ideas on how to achieve this? Changing each first line to the bolded paragraph style by hand is becoming really tedious. Thank you all in advance. 

 

 

TOPICS
How to , Type

Views

188

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 30, 2023 Apr 30, 2023

Copy link to clipboard

Copied

"... where it finds two paragraph returns with format A"

This implies that the space between Website and the subsequent Business Name is just another whack of the Return key, right? That's too bad, but it'll work in your favor. 

 

You need to write a query that finds the Business Name, but excludes surrounding text and paragraph returns. So I'd suggest you use a non-matching group; in this case, a positive lookbehind. We're looking for the whole line after two paragraph returns, right?

 

(?<=\r\r).+

 

The parentheses enclose a group, and that group says "find two paragraph returns in a row, but don't include those two paragraph returns in what is found." That's what (?<=stuff) means. "Find stuff that precedes my query."

 

If this doesn't work for you, can you post some examples? Like perhaps some screenshots, or a little demo file, and perhaps the actual query you are using. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 30, 2023 Apr 30, 2023

Copy link to clipboard

Copied

LATEST

You could try the following

\r\s*\r\K.*\r

The idea is the same as @Joel Cherney. I also take care of possible whitespaces in the empty paragraph. The \K is used to expunge the match before it from the final match result, something similiar to what (?<=) used by Joel.

Now I see that you say you are trying to find two paragraph returns with format A applied. If you need to check for format as well then we could have a problem if the "Business Name" has a different paragraph style applied to it. Because the grep query has to find the next line after two paragraph returns and if you check for format, it would apply to the whole grep string and the search would fail.

You could also try using Next Style property of Paragraph Style applied to the empty paragraph.

-Manan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines