1

I am trying to typeset a dictionary, and at the end of many of the word entries, there are additional references the reader can consult.

...definition here.

For further reference, apple; fruit; tree

I am trying to create a GREP that allows me to select all letter characters only (not the semicolons) between "For further reference," until the end of the line, which terminates in a carriage return. The matching characters will all be italicized. So far, I have something that will match every character (including the semicolon):

(?<=For further reference,)(.)*(?=\n)

but when I attempt to modify this to only select [a-zA-Z] the whole thing borks.

Does anyone have any tips? This is driving our team absolutely mad 🙃


Edit: in the same block of text (and in the same paragraph style), directly above the "for further reference,", there can also sometimes be found the text

...definition here.

See also ORANGES; PEARS; MANGOES
For further reference, apple; fruit; tree

The terms following "See also" should not be italicized.

I confess I am not the one doing the actual typesetting; I do web development but am asking this question for my colleague. So, my apologies if I am misusing some InDesign terminology. And for not providing the complete information from the start.

1 Answer 1

2

Solution

((?<=For further reference,)[^;]+)|((?<=;)[^;\n]+)

Explanation

( - begin subexpression

(?<=For further reference,) - a Positive Lookbehind that matches what comes after For further reference,

[^;]+ - match one or more characters that isn't a ;

) - end subexpression

| - or

( - begin subexpression

(?<=;) - a Positive Lookbehind that matches what comes after a ;

[^;\n]+ - match one or more characters that isn't a ; or a \n

) - end subexpression

Used as a Grep Style

Note

You say that your text "terminates in a carriage return", but the GREP expression that partly works for you contains a Forced Line Break (\n), so that's what I've used here (although I don't understand why you would use that).

If instead you are using Paragraph Return (by pressing Enter) you can just use \r instead of \n.

Edit due to comments

It seems that my solution interferes with other places with the same Paragraph Style where semicolons occurs.

How about having one GREP Style that applies an italic Character Style to (?<=For further reference,).* and then another GREP Style that cancels the italic (by applying "regular" or whatever it's called in the font in use) for ; afterwards?

This will of course interfere with semicolons elsewhere in the paragraph which you actually want to be italicized.

5
  • But this will find any string following a semicolon anywhere, won’t it? So if there’s a semicolon somewhere in the definition itself (not unusual in dictionaries), it will match anything after that semicolon too. Aug 26, 2022 at 15:25
  • Hi, thanks so much for replying! This does do the job of matching the terms that we want, but yes, as Janus has said this is matching anything after a semicolon anywhere in the document. Aug 26, 2022 at 16:58
  • Then give the line with "For further reference," its own paragraph style? I assumed it already had that.
    – Wolff
    Aug 26, 2022 at 17:00
  • I am sorry! I was incorrect; it is not matching anywhere in the document. There is text directly above that which I described that is also picking up the italicized behavior, and is a part of the same paragraph style. Please see the edit above, and thanks again for looking at this. Aug 26, 2022 at 17:10
  • No need to be sorry. It's just really hard to answer GREP questions in general without knowing exactly how the whole document is set up. I gave it another go...
    – Wolff
    Aug 26, 2022 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.