Forums › Adobe After Effects Expressions › Highlight specific word with a symbol in front supporting line breaks
-
Highlight specific word with a symbol in front supporting line breaks
-
Frederik Damsgaard
January 26, 2023 at 5:07 pmHi
I found this expression making it able to color fill a specific word in a text layer.
words = text.sourceText.split(” “);
currentWord = words[textIndex-1];
if(currentWord.charAt(0)==”@”){color=100}else{color = 0};
[color,color,color]
It is used with fill color animator + expression selector based on words.
I can’t get it to work if the text is in two or more lines. Is it possible to get to work in multiple lines?
Also, would it be possible to instead do the expression, so that it color fills multiples words within the symbols < and >.
“Here is an example <where these four words>
should be colored”
-
Dan Ebberts
January 26, 2023 at 5:28 pmTry this for the first one:
words = text.sourceText.split(/\s+/);
words[textIndex-1][0] == "@" ? 100 : 0 -
Frederik Damsgaard
January 27, 2023 at 7:46 amAmazing, this is so much more elegant, and it works too, haha!
Thank you!
Log in to reply.