Skip to main content
Participant
February 28, 2017
Question

Grep - How to find non-italics characters followed by italics

  • February 28, 2017
  • 3 replies
  • 2308 views

Hello everyone...

Is there a way to grep all non-italics characters followed by an italics punctuatiob, e.g., serach for "Review of Religions," in this word, the punctuation "," is not italics, I would like to serach of all types of punctuation that are not italics, and change them to italics, same would be the case for bold, and bold-italics.

Another way looking at it would be a grep that could search for any italics character followed by a regular punctuation, and a bold character follwed by a non-bold punctuation, and a bold-italics character followed by a non-bold-italics character.

Thanks in advance!

This topic has been closed for replies.

3 replies

Participating Frequently
August 25, 2022

I found a way,
Find: (?<!.)[:,;")!?%]|["(](?!.)

Find format: font style regular (or if you work with characterstyles, like I do chacacter style: [none])

 Change format: italic (or character-style: italic)

 

Explanation: It looks for every character in the list [:,;")!?%] that is preceded by any character that is not regular/has no character style OR every character in the second list ["(] that is followed by a character that is not regular/has no character style.

It's not perfect. I would like to optimize it so that it won't find brackets in which the text is not fully italic (e.g this text). But I couldn't find out how. It does work well enough though.

Peter Kahrel
Community Expert
Community Expert
March 2, 2017

This is not something you can just like that with InDesign's Grep. The Grep manager that Gert mentioned can't do that, don't know about Automatication's solution. If Michael's solution doesn't work for you, you can change italic formatting to text tags, so that this:

Review of Religions,

(where the comma is not italic) is rendered like this:

<i>Review of Religions</i>,

You can then search for (</i>)([[:punct:]]) and replace with $2$1 to move the punctuation inside the italics. Then you change the italic tags back to italic formatting. This method is described in detail in https://indesignsecrets.com/issues/issue-76-publish-anywhere. You'd do that again for bold and bold-italic. You can store the queries and rerun them. It's a method I've been using a lot, and it works well.

Peter

gert verrept
Inspiring
March 2, 2017

Peter, you're right. It cannot be done by either. I thought it could be chained, but no. The Grep manager and the MFC are useful solutions when grep queries can be executed one after the other. We use it a lot during layout of texts coming from Word.

Mike Witherell
Community Expert
Community Expert
March 1, 2017

I would run this 3 times:

Find What: (\,|\;|\:)

Find Format: Regular

Change To: leave blank

Change Format: Character Style Italic

The second time you run it I would reset to Bold Character Style.

The third time I would run it I would reset to Bold Italic Character Style.

Automatic? No. But it would allow you to inspect each occurrence, and it would only take 5 minutes.

Mike Witherell
gert verrept
Inspiring
March 2, 2017

Look for grep manager script or the multi find and change from automatication. The first is free. Once you have the query you can load them in a set and ececute them all in one click.