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

GREP search with exception

Explorer ,
Jun 15, 2023 Jun 15, 2023

Copy link to clipboard

Copied

Hello InDesigners,

Having still not mastered GREP, I'd love it if someone could help me work out a way to search for a result but exclude particular elements.

 

I'm working on an index for a multi-volume book, and want to make sure all entries are formatted properly. Each should look like this, and each is preceded by a carriage return:

Smith, Jim (carpenter); training of, 4.150; work of, 3.120, 145

I'm keen to make sure the semicolons that come after each heading (in the example above, it's the semicolon after "(carpenter)") are in place, as I may have missed a few, which results in this kind of thing:

Smith, Jim (carpenter), training of, 4.150; work of, 3.120, 145

The Grep code I'd like would say something like 'after a carriage return, search for any number of letters, including any number of white spaces (and forced line breaks) up to the first digit, although if there's a semicolon in there, ignore that result, and move on to the next.'

The following worked:

(\r)([\l\u]+)(\s)([\l\u]+)(\,)(\s)(\d)

The only way I could think of to broaden it was to add an extra "(\s)([\l\u]+)" in the middle multiple times, which I did, and found more incorreclty styled entries, but I fear some others will have slipped through.

If anyone can help, I'd be very grateful.

TOPICS
Experiment , How to

Views

233

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

Guide , Jun 15, 2023 Jun 15, 2023

Find: ,(?=\h(([\l\u]+)\h)+(?2),\h\d)

Replace by: ;

 

(^/)  The Jedi

Votes

Translate

Translate
Guide ,
Jun 15, 2023 Jun 15, 2023

Copy link to clipboard

Copied

Find: ,(?=\h(([\l\u]+)\h)+(?2),\h\d)

Replace by: ;

 

(^/)  The Jedi

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
Explorer ,
Jun 19, 2023 Jun 19, 2023

Copy link to clipboard

Copied

LATEST

Thanks so much for this, @FRIdNGE. That's very useful in helping me to straighten everything out.

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