How could I use Indesign’s find by grep feature to find and format words between to underscores?

Lets say I have a bunch of text that needs to be italic. Throughout my text, italics are represented as:

_word_
_any_
_car_

And so on…

I want to find these, and replace them with word, car, any, and the like.

I was able to find one word with this expression. \_.+\_

I’m new to inDesign, but I am familiar with using Regular Expressions within Ruby. Ideally, I would like to remove the underscores and format them as Italic at once, using a style.

Answer

Create an italic character style (set some text to italic, select it and create a new style with the character styles dialogue)

In the paragraph styles dialogue, clear overrides to clear your italicized text and then right click on Body Text, selecting “Edit Body Text”

Click on GREP styles and then New GREP style.

Select the italic style you created previously and enter your grep expression

\_(.*?)\_

Should find all the words between underscores.

Click OK to apply the character style to the paragraph style, and viola – all text set to that paragraph style will have words between underscores italicized

Attribution
Source : Link , Question Author : Astor139 , Answer Author : user22723

Leave a Comment