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

GREP Help- multiple words end of paragraph only

Community Beginner ,
Nov 06, 2020 Nov 06, 2020

Copy link to clipboard

Copied

I'm new to GREP styles in InDesign. I've been searching and studying and can't find an answer to this yet, and I need to solve this for a project. I have a heading that shows readers what page/section they are on using words or phrases separated by pipes. I need to set all the words at the end of the series (after the last pipe) to Light Yellow. So far I can only get it to do this if there's one word, but I need it to set in the case of multiple words (2 or more) as well.  In this example, you can see my problem. The \w+ gets me what I want if there's only one word, but as you can see, if there's more than one word there's no change because the space is not a word character.

location example.png

If I use .+ or .+? it works for multiple words, but since the pipe is included in "any character" it finds everything after the first pipe to the end of the story. I need only what's after the last pipe in the story colored Light Yellow. 

location example 2.png

Any help in solving this would be greatly appreciated. Maybe I'm just going about this all wrong?

Steve

TOPICS
How to , Scripting , Type

Views

998

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

correct answers 1 Correct answer

Community Expert , Nov 06, 2020 Nov 06, 2020

Try this:

\|\K[^|]+\r

Capture d’écran, le 2020-11-06 à 12.31.49.jpg

Votes

Translate

Translate
Community Expert ,
Nov 06, 2020 Nov 06, 2020

Copy link to clipboard

Copied

How about the following

\|[^\|]+$

-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
Community Expert ,
Nov 06, 2020 Nov 06, 2020

Copy link to clipboard

Copied

Try this:

\|\K[^|]+\r

Capture d’écran, le 2020-11-06 à 12.31.49.jpg

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 Beginner ,
Nov 06, 2020 Nov 06, 2020

Copy link to clipboard

Copied

Thank you Jean-Claude! That worked after replacing the \r with \z because there's no paragraph mark at the end, just an end of story mark. edit: I found that $ at the end works also, which is strange because theoretically \r is the same as $, right?

 

That said, I'm not clear on how your expression works. I'm not familiar with \K so I looked for it, and my results say it means "lookbehind, clear position" which I don't really understand. Using that, I read your expression as searching for:

 

pipe character > lookbehind, clear position > exclude pipe character > one or more times > end of paragraph (or end of story)

 

I'm confused. Could you please explain \K? 

 

 

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
Guide ,
Nov 06, 2020 Nov 06, 2020

Copy link to clipboard

Copied

What's the problem with

 

[^|]+$

 

?

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 Beginner ,
Nov 06, 2020 Nov 06, 2020

Copy link to clipboard

Copied

Marc, that works too! But I don't understand why. You're just telling it to exclude pipes one or more times to end of paragraph, but I don't see where you're telling it to find something? How does it this work? Grateful for the help. 

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 ,
Nov 06, 2020 Nov 06, 2020

Copy link to clipboard

Copied

LATEST
[^|]+

This means anything that is not a pipe, one or more time.

 

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