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

Grep style for bolding through a second m-dash

New Here ,
May 22, 2023 May 22, 2023

Copy link to clipboard

Copied

Hi there, I don't know how to use GREP very well and I'm looking for a way to bold dictionary entries through the second instance of an m dash. Some entries just have one em-dash, which I've coded for but I don't know how to code for instances when 2 em-dashes are used. (See the last example in the list below.)

 

Screen Shot 2023-05-22 at 3.32.12 PM.png

TOPICS
How to , Scripting

Views

447

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 , May 22, 2023 May 22, 2023

Grep is great and can be complex.

 

There's a different function better suited to this in InDesign - called Nested Styles

 

Em Dash is not an option in the drop down area of the Nested Style

But you can just copy and paste the Em Dash in there.
Sample file attached

 

EugeneTyson_0-1684817038865.png

 

 

 

Votes

Translate

Translate
Community Expert ,
May 22, 2023 May 22, 2023

Copy link to clipboard

Copied

This would hit everything before the last emdash in the line: ^.+~_

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 ,
May 22, 2023 May 22, 2023

Copy link to clipboard

Copied

Hi @MyrtleTree, here is one that captures up until the 2nd em-dash.

^([^~_\r]*~_){1,2}

 

However, I wouldn't suggest putting that in a grep style because in my experience there are often exceptions which make things awkward later on. So when I set up a grep style like this I actually use the grep (like Brian's or mine above) to do a search and replace to add a special marker character at the end of the found em-dash. It should be a zero-width character, eg. a non-joiner or a zero-width-space. The replacement (using a non-joiner ~j) would be:

$0~j

 

Then I set up the grep style like this:

^[^~j]*~j

 which will capture everything up until the first non-joiner character. See screen shot, showing invisibles:

 

Screenshot 2023-05-23 at 08.13.47.png

 

The reason I do this is (a) initially it gives the same result as a straight grep style, but (b) when an exception occurs, you can just manually move the non-joiner character to where you want it. (Note: to select zero-width characters you need to use the left or right arrow-keys with shift.)

 

Try the attached demo file if it helps.

- Mark

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 ,
May 22, 2023 May 22, 2023

Copy link to clipboard

Copied

Grep is great and can be complex.

 

There's a different function better suited to this in InDesign - called Nested Styles

 

Em Dash is not an option in the drop down area of the Nested Style

But you can just copy and paste the Em Dash in there.
Sample file attached

 

EugeneTyson_0-1684817038865.png

 

 

 

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 ,
May 23, 2023 May 23, 2023

Copy link to clipboard

Copied

TIL you can copy other characters into the Nested dropdown. Thanks Eugene. OP, you'll want to change the 1 to 2 in Eugene's screenshot. 

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 ,
May 23, 2023 May 23, 2023

Copy link to clipboard

Copied

Yes they can change it to suit their own needs. I was working off 4 hours sleep 

 

You can add as many into the list too as you need - just click New Nested Style and another option will be added.

 

It's quite versatile for this sort of thing.

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 ,
May 23, 2023 May 23, 2023

Copy link to clipboard

Copied

LATEST

Excellent thinking! I didn't even think of nested styles.

- Mark

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