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

InDesign GREP Style Help

New Here ,
Apr 07, 2022 Apr 07, 2022

Copy link to clipboard

Copied

I've used GREP styles on and off, but I struggle to wrap my head around it and I can't find an answer that works for what I'm trying to accomplish...

 

The document I'm working with has a list of businesses setup like this:

 

Business Name (em space) Address (em) Phone Number (em) URL (em) Facebook URL (em) Instagram URL (paragraph break)

 

I use a nested style to make the Business Name bold ("up to 1 em space") and then I have a GREP style to make the URL bold. It works... but it will also bold characters in the Facebook and Insta URLs. I want the style to just apply to the URL and leave the Facebook and Insta alone. 

 

This is my GREP style as it is:

[\l\u\d.]+(.com|.ca)

 

So anytime the letters "ca" or "com" show up in a Facebook or Insta URL it bolds them as well, plus any letters/digits preceding that.

 

With each business listing there is an ! in the text right before the Facebook URL—I use another GREP style to recognize the exclamation point and convert it to the typeface Social Shapes and give me a nice little Facebook icon. I've tried to figure out how to stop the GREP match when it encounters an exclamation mark, but this is beyond my skillset. I have no idea how else to make this work...

 

Can anyone help? TIA

TOPICS
How to

Views

460

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 , Apr 07, 2022 Apr 07, 2022

I could not edit my reply, but here is the way to use the exclamation mark as end indicator. It sets an em space followed by a exclamation as a positive lookahead, so that the code only picks up urls followed by an em space and an exclamation.

[\l\u\d.]+(.com|.ca)(?= \!)

 

Votes

Translate

Translate
Community Expert ,
Apr 07, 2022 Apr 07, 2022

Copy link to clipboard

Copied

It worked for me on my sample when I added a positive look-behind with four digits together followed by an em space.

(?<=\d{4} )[\l\u\d.]+(.com|.ca)

 

 This picked up only the URL directly following the phone number. 

(if the phone numbers has a different format, or sometimes includes an extension, this code would need to change)

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 07, 2022 Apr 07, 2022

Copy link to clipboard

Copied

I could not edit my reply, but here is the way to use the exclamation mark as end indicator. It sets an em space followed by a exclamation as a positive lookahead, so that the code only picks up urls followed by an em space and an exclamation.

[\l\u\d.]+(.com|.ca)(?= \!)

 

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
New Here ,
Apr 11, 2022 Apr 11, 2022

Copy link to clipboard

Copied

Thank you, this worked the best and captured almost every single URL and left all the Facebook and Instagrams alone!

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 11, 2022 Apr 11, 2022

Copy link to clipboard

Copied

LATEST

Doesn't my grep work for you?

From experience, the other grep does not find many URL.

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 08, 2022 Apr 08, 2022

Copy link to clipboard

Copied

How about

~m\K\S+\.c(a|om)(?=~m\!)

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