Skip to main content
beg87656411
Known Participant
January 18, 2019
Question

Complex Find/Replace GREPS Script: Any advice very welcome!

  • January 18, 2019
  • 2 replies
  • 1608 views

Hi all -

I have a set of text in Indesign that I want to use a find and replace function. Let us this random Wikipedia article as an example:

Prior to the show, Jaymes gained popularity as an actor on Santa Barbara and also as a stand up comedian, including on the Fox network on the critically acclaimed The Sunday Comics.

I also have a set of characters that I would like to highlight in red (whatever to distinguish them from the rest of the text):

P s J y a S x C a T S C

I would be able to do this manually but in reality I have thousands of these characters to find in a large text file of over 100,000 digits (its will be very laborious). I also only want to highlight these in consecutive order through the text, so first P, and then the first s after P, and the first J after s and so forth. I do not want to highlight ALL the P's or ALL the S's etc.

If there a formula to do this in Find and Replace with TEXT or  GREPS?

Many thanks for your support.

This topic has been closed for replies.

2 replies

beg87656411
Known Participant
January 18, 2019

Thanks Scott for your help here.

Im probably not being that precise (do excuse me):

I dont want to find these characters as a defined string one next to each other 'P s J y a S x C', I want to locate them within the text as they are found without inputting them all in individually. If I search for 'P s J y a S x C' nothing would come up as they are not to be found next to each other in the text.

I have added the letters in Bold where they first show up in the text below:

Prior to the show, Jaymes gained popularity as an actor on Santa Barbara and also as a stand up comedian, including on the Fox network on the critically acclaimed The Sunday Comics.

I want to see if I can find out a way that I can input this text 'P s J y a S x C' into a Find function and then let the programme locate the first instance of each letter and then following on from that convert it to red/italics/bold (anything to differentiate it to other).

Its probably easier to explain using words:

I do like dogs, but not as much as cats, dogs are definitely my favourite animal over cats.

'DOGS CATS'

I do not want to make red every dogs or cats just the first instance of them in the text.

Does this make more sense?

hammer0909
Community Expert
Community Expert
January 18, 2019

Well for starters, you could simply put a pipe symbol (|) between each letter in the Find what field in the GREP section of the Find/Change dialog box and then in the change format section choose the formatting you want to apply. The pipe symbol is the "or" operator and will find any of the letters on their own. In the screen shot below I'm using a red character style. That will find any instance of each letter in the text. Now if you can narrow down more specifics of when and where the letter will occur, we may be able to assist you further.

Scott Citron
Legend
January 18, 2019

The first part is easy. Copy the text you want to replace and paste it into the Find what: field of InDesign's Find/Change dialog. Type or paste the replacement for the Find text into the Change to: field. Click Find Next and replace accordingly. If you're confident of what you're doing you can save time by clicking Change All.

If I understand you correctly, you want to find this string: P s J y a S x C a T S C and change it to red? Right? If so, see my screen shot. You could also create a GREP Style to apply Red to this string automatically.