Skip to main content
vanillasoap
Participant
September 16, 2017
Answered

Grep style between punctuations

  • September 16, 2017
  • 4 replies
  • 740 views

For my footnotes (Chicago manual style) I want to add a grep style for the book titles.

The following is an example where the bold text should be applied:

Brekke, Nils Georg 1938, Per Jonas 1929 Nordhagen, and Siri Skjold 1958 Lexau. Norsk Arkitekturhistorie: Frå Steinalder Og Bronsealder Til Det 21. Hundreåret, Oslo: Samlaget, 2008. 336.

How would the grep style code look like? All book titles start with ". " and ends with ", " following the published year.

Thanks in advance

This topic has been closed for replies.
Correct answer winterm

Couldn't get amaarora's regex to work, so here's mine:

(?<!\d)\.\s\K[^,]+

Seems to work on your exact sample, not sure about the whole picture, though.

4 replies

pixxxelschubser
Community Expert
Community Expert
September 19, 2017

vanillasoap​,

no more interest?

Jongware
Community Expert
Community Expert
September 17, 2017

I suggest to not use a GREP style for this and manually apply the character style where needed. GREP styles are great, but they are also dumb as a bag of rocks.

The "manually" part is only to distinguish from "fully automatic". You can still use any appropriate GREP in Find/Change to locate a next possible candidate title. The difference is that you are in control, only applying it where needed.

winterm
wintermCorrect answer
Legend
September 16, 2017

Couldn't get amaarora's regex to work, so here's mine:

(?<!\d)\.\s\K[^,]+

Seems to work on your exact sample, not sure about the whole picture, though.

amaarora
Inspiring
September 16, 2017

Hi,

Thanks winterm. Mine dint work and now i know why(just learnt the correct working of the "any letter" wildcard and the use of "\K"). Below is the result of my expression.

Thanks once again.

-Aman

winterm
Legend
September 16, 2017

Hi Aman,

You're most welcome! BTW, my regex could be a bit more compact: \D\.\s\K[^,]+

Logic remains exactly the same.

amaarora
Inspiring
September 16, 2017

Hi,

Not really good with GREP but i think the below expression should solve your problem

Do look out for cases in which this fails.

-Aman