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.
Find: ,(?=\h(([\l\u]+)\h)+(?2),\h\d)
Replace by: ;
(^/) The Jedi
Copy link to clipboard
Copied
Find: ,(?=\h(([\l\u]+)\h)+(?2),\h\d)
Replace by: ;
(^/) The Jedi
Copy link to clipboard
Copied
Thanks so much for this, @FRIdNGE. That's very useful in helping me to straighten everything out.