Copy link to clipboard
Copied
Hi, I have very basic AE skills and can't figure this one out. I only want every "C" to be yellow and don't want to manually change it every time I change the words.
Tried an expression that looks for every space " " and then changes the color of the character right next to that, which would be the C's:
var userText = text.sourceText;
if (userText.length > 0) {
var modifiedText = userText.replace(/ (\w)/g, " <span style='color:#FCD527'>$1</span>");
modifiedText;
} else {
""
}
I'm getting "Error, couldn't turn result into numeric value"
Thank you for any ideas you may have.
Copy link to clipboard
Copied
If you add an Expression Selector and add this expression to the Amount property, it should get you close to what you're after:
userText = text.sourceText.value;
userText[textIndex-1] == "C" ? 100 : 0
Copy link to clipboard
Copied
I am not sure I understand how this could work. If you add a Fill color, you can only fill the characters based on the start, end, or offset.
If you use an expression on the source text to change the color, you can only do that once, not for every instance of a character like "c."
It would be useful to be able to designate a character and fill every instance of that character with a different color, but I don't see any way to do that with the current text engine in After Effects.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
The Expression Selector is a feature that I have never used before. Thanks Dan, I learned something new from you again.
Copy link to clipboard
Copied
A better answer for this question is to use an expression selector to look for a line break in the previous index, that way there are no conflicts if any of the words contain a 'c'. Its pretty simple to check for a space to apply the animator to the first letter of every word:
if (textIndex == 1) {100;} // Set the first character
else {
PREV = text.sourceText.value[textIndex-2];
PREV == ' ' ? 100 : 0;
}
But it gets more complicated when you have line breaks because the expression selector doesn't count them as characters, but the source text does... or maybe it's the other way around? I don't know, it's hurting my brain trying to verbalize it. What I do know is that you have to shift the index by 1 for every line break before the current index, sort of like this:
if (textIndex == 1) {100;} else { // Set the first character
src=text.sourceText.value;
upToIndex = SRC.substring(0, textIndex-1);
lineBreaks = upToIndex.split(/\r|\n/).length-1;
PREV = SRC[(textIndex-1)+lineBreaks];
PREV == '\r' ? 100 : 0;
}
BUT this won't always work because the 'upToIndex' is checking the wrong spot and may already be on the next line. I don't have time to figure it out at the moment, but it's almost there (I think).
Copy link to clipboard
Copied
Take a look at the Expression that selects a single alphanumeric - it supports multiple-line input strings, has a case-sensitive checkbox, multiple searches, and an instancing delimeter.
https://www.broadcastgems.com/post/the-text-selector-expression-is-arguably-the-most-elusive-adobe-a...