Skip to main content
Participant
May 5, 2020
Question

Underline part of a word

  • May 5, 2020
  • 3 replies
  • 1100 views

Dear InDesign community,

300 pages have been copied into InDesign. Unfortunately, underline within words has been removed. Is there a simple way for the word "Shah" to be replaced with "Shah" and not every "Sh" word being underlined?

There are many other "Sh" words that do require underline to, such as "Shaykh" and "Shahíd" and "Báshí", so due to this complexity, "Change All" is not likely an option, but even one at a time with "Find/Change" would be better than copying and applying 300p of styles to paragraphs.

Thank you in advance.

This topic has been closed for replies.

3 replies

Community Expert
May 6, 2020

Try something like

 

 

\bSh(?=ah|am|adow\b)

 

 

Where you can add each variation of characters that can come after Sh by adding a | character followed by the character sequence. See a sample below

-Manan

 

-Manan
Community Expert
May 5, 2020

Michael beat me to it :), but i have a slightly different variation

Sh(?=ah\b)

To cater to cases where the word is separated by something other than a space character. \b here defines the word boundary and is a zero length match. Rest all is explained brilliantly by Michael.

 

-Manan

-Manan
Michael Bullo
Community Expert
Community Expert
May 5, 2020

Good call Manan.

Michael Bullo
Community Expert
Community Expert
May 5, 2020

 

Created a Character Style called "underline" that just underlines text.

 

Created a Paragraph Style called "body" that is applied to all of the text.

 

Within the body Paragraph Style created a GREP Style which applied the underline Character Style whenever it identified "Sh(?=ah )" where...

 

Sh
Represents the characters "Sh"

 

(?=ah )
Looks for the presence of the characters "ah " directly after the originally detected characters "Sh". This takes advantage of a feature called a Positive Lookahead.

 

One of the best parts of this method is that it is dynamic. Any text that you add that has the body Paragraph Style applied to it will automatically underline the first two letters of the word Shah.

 

If you are liking what this can do but have no idea what GREP is, feel free to ask away. We love GREP in this forum 😉