Skip to main content
Participant
July 26, 2017
Answered

GREP find/replace

  • July 26, 2017
  • 2 replies
  • 1450 views

Trying to figure out GREP find and change code for a particular character in this case below an

en dash: (~=) to the end of the paragraph

Arch A. Moore, III – Executive Vice President, Middleburg Market Executive

to

Arch A. Moore, IIIExecutive Vice President, Middleburg Market Executive

This is probably a very ease one. Appreciate the help if you can give it.

Thanks,

Scott

This topic has been closed for replies.
Correct answer Scott Falkner

Easy with a GREP Style, no need for search and replace.

The GREP expression is (?<=–).+

That’s an en-dash before the closing parenthesis. In this example the en dash is not italicized.

(?<=

This is a positive look behind. It finds text that follows the specified character or characters.

The en dash for the positive look behind to find.

)

The closing parenthesis for the positive look behind expression

.

Wildcard, meaning any character

+

Repeat one or more times. This is applied to the wildcard, meaning the expression will find any characters after an en dash up to the end of the paragraph.

2 replies

Erica Gamet
Inspiring
July 28, 2017

Or even a nested style, using None through the first dash, and italic through the first forced line break.

Scott Falkner
Community Expert
Scott FalknerCommunity ExpertCorrect answer
Community Expert
July 26, 2017

Easy with a GREP Style, no need for search and replace.

The GREP expression is (?<=–).+

That’s an en-dash before the closing parenthesis. In this example the en dash is not italicized.

(?<=

This is a positive look behind. It finds text that follows the specified character or characters.

The en dash for the positive look behind to find.

)

The closing parenthesis for the positive look behind expression

.

Wildcard, meaning any character

+

Repeat one or more times. This is applied to the wildcard, meaning the expression will find any characters after an en dash up to the end of the paragraph.

Obi-wan Kenobi
Legend
July 26, 2017

–\h\K.+

(^/) 

see888Author
Participant
July 26, 2017

Thanks Obi-Wan!