• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Automatically changing the color of the first letter of every word within a list of text

New Here ,
Jul 31, 2023 Jul 31, 2023

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"

 

Nicolas22126466f746_0-1690827879800.png

 

Thank you for any ideas you may have. 

 

TOPICS
Error or problem , Expressions , How to

Views

335

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 31, 2023 Jul 31, 2023

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

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 31, 2023 Jul 31, 2023

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.

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 31, 2023 Jul 31, 2023

Copy link to clipboard

Copied

Is this not what he's asking for?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 31, 2023 Jul 31, 2023

Copy link to clipboard

Copied

LATEST

The Expression Selector is a feature that I have never used before. Thanks Dan,  I learned something new from you again.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines