Skip to main content
Cheryllion
Known Participant
April 4, 2025
Question

Find and replace the color or type style of a certain bit of text

  • April 4, 2025
  • 1 reply
  • 474 views

I have a project where I am given a couple of pages full of text. Let's say one part looks like this: 

 

"Lorem [A] ipsum dolor sit amet, [B] consectetur adipiscing elit. [C] Phasellus imperdiet nisl malesuada ante vulputate, nec [A] ultricies ante pharetra. [Bb] Praesent consectetur [Gm] mauris sit amet velit venenatis, [C] id ornare lacus posuere."

 

What I need to do is take all of the text that is in brackets (ncluding the brackets) and make that bold and a different color. Is there a way to do this? I can figure out how to select it, using find and replace, but I can't change anything but the actual text with that. Right now I find myself going in and selecting each character then making the change. Seems like there's an easy fix I'm not thinking of. 

 

I also know there's the possibility that someone will come here and say "just use a custom script" or something like that. I am completely dense when it comes to that kind of thing.

 

TIA!

1 reply

RobOctopus
Inspiring
April 4, 2025

if the text you are trying to target is actually just the letter A or B then this becomes a lot easier. you would essentially have to search through the text in the file. find the characters that match what you want (ie [A],[B], etc) and then apply specific styling to it.

pseudo code
var textbox = find the text frame
characterindex = contents.search("[A]")
textbox.characters[index].characterAttributes.fillColor = assign new color
textbox.characters[index].textFont = app.textFonts.getByName("HelveticaNeueLTStd-BlkCn") assign new font name

without knowing exactly what you are searching for and changing into along with how the files may or may not be set up, the complexity of this code varies greatly.

Cheryllion
Known Participant
April 4, 2025

Thank you for responding -- But I have no idea what to do with the code you typed up.

I would like to grab ALL of the text that is within brackets, and the brackets. So I want my search to be for something like "[*]" and to change it to, say, REDSWATCH and BOLD.

 

So, this... "Lorem [A] ipsum dolor sit amet, [B] consectetur adipiscing elit. [C] Phasellus..."

 

...would become this... "Lorem [A] ipsum dolor sit amet, [B] consectetur adipiscing elit. [C] Phasellus..."

 

...in one fell swoop. I was hoping to find a setting that is all ready to use, as the "Find/Replace" setting is the closest -- can I type code in the find and replace boxes?

RobOctopus
Inspiring
April 4, 2025

no, this is something you'd have to script to do. its possible someone has created a robust find/replace for illustrator thats similar to indesign, but otherwise you'd have to either learn some coding or have someone here write it out and explain how to use it.

i imagine a semi-generic script could be written that allows you to type in what you're searching for, do some color selection, and then pick the desired typeface. 

 

is this a project that needs to be done in illustrator? becuase out of the box indesign has great features for handling text