Activity › Forums › Adobe After Effects Expressions › Specific word in paragraph be a different color
-
Specific word in paragraph be a different color
Arav Roy replied 3 years, 11 months ago 10 Members · 28 Replies
-
Mac Lad
October 7, 2017 at 6:22 pmSorry Dan, i didn’t put expression selector…but now its working fine ….just for a query can this be worked for multiple words..?
Is that possible…? -
Liam Campbell
October 7, 2017 at 7:28 pmThe only part of this that I don’t understand is the [textIndex -1] what exactly is this searching for?
-
Dan Ebberts
October 7, 2017 at 8:41 pmYou could set it up for multiple words like this:
wordArray = ["one","two","three","four"];
words = text.sourceText.replace(/^\s+/, "").split(/\s+/);
val = 0;
for (i = 0; i < wordArray.length; i++){
if (words[textIndex-1] == wordArray[i]){
val = 100;
break;
}
}
val
Dan
-
Dan Ebberts
October 7, 2017 at 8:47 pmwords is an array of the words in your text, so it is zero-based (indexing starts with zero). textIndex is the word index into the text itself. It starts with one, so you have to subtract one to retrieve the appropriate word from the array. You wouldn’t have to go through all this if you could use textIndex directly to access the text that it’s indexing.
Dan
-
Mac Lad
October 8, 2017 at 7:07 amThanks Dan for awesome help… It also worked with multiple colors by just duplicating Animator and replacing the words from array and changing color parameter
-
Raph Nicolas
December 28, 2017 at 10:30 pmHi guys, I’m having a similar issue but wondering if this could be adapted to work with external text. I’m importing copy from a spreadsheet (with Dataclay’s Templater) and would like to choose in the spreadsheet which words get highlighted (e.g. yellow instead of white) in the comp’s text box. What would this formula look like if a special character (for example “*”) in the text field marks the word with different color? e.g. “Lorem ipsum *dolor sit amet*, consectetur adipiscing elit” returning “dolor sit amet” in yellow while stripping * away?
-
Roman Lehmann
March 25, 2018 at 8:12 pmI have a text layer and a solid. Is it possible to change the opacity of the solid if the source text in the textlayer equals the word “SUI”?
Any help is appreciated! -
Dan Ebberts
March 25, 2018 at 8:46 pmSomething like this:
if(thisComp.layer(“text”).text.sourceText == “SUI”) 100 else 0
Dan
-
Matt Volp
March 31, 2018 at 7:37 pmHi Dan,
What about if the word isn’t surrounded by whitespace?
For example:
string = “Hello you people!”
I want to highlight “people” “you”. Not “people!”.
Reply to this Discussion! Login or Sign Up