Activity › Forums › Adobe After Effects Expressions › Text string problems
-
Filip Vandueren
July 8, 2022 at 12:00 pmHi Nick, you’re correct the setup now only seems to catch 1 positive and 1 negative term.
I would approach it a bit differently:
- remove the separate red and green animators (but keep the expressions of the sourceText)
- make the text Black in the Character palette
- add a textanimator that colors the RGB Fill of the letters White.
- give this text animator an expressions selector, make sure to set it “based on words”
- here’s the expression, by “partially” selecting the amount the black letters become white, we can actually color it in. The resulting value of an expression selector can actually have up to three dimensions, and in this case that corresponds to RGB.
words=text.sourceText.trim().split(/\s+/);
i=textIndex-1;
if (words[i].match(/-[0-9\.]+%/)!==null) {
[100,0,0]; // red
} else if (words[i].match(/\+[0-9\.]+%/)!==null) {
[0,100,0]; // green
} else {
[100,100,100]; // white
}This way you can set up even more regexp matches, for example:
… } else if (words[i].match(/[0-9\.,]+€/)!==null) {
[80,70,0]; // yellow
} else { … -
Nick Kennedy
July 8, 2022 at 12:18 pmHi Filip, yes!!! this appears to work just right! Many Many Thanks for your help.
-
Nick Kennedy
August 3, 2022 at 2:07 pmI just wanted to thank again Filip and Andrei for helping me out on this project. Creative cow is such a great place to get help, I hope one day to be knowledgeable enough to help people out on these forums as well, but until then, I’ve attached a copy of the final project in case anyone would like to take a look at this. I actually wanted to create a MOGRT for premiere pro, so that the editors could simply swap out the CSV file but unfortunately it doesn’t seem to work well. I may well open another Forum Thread over on the Premiere Pro Forum. In the meantime we are using direct link to the AE Comp and simply saving the new CSV file over the old one. Anyone who sees this and has experience working with CSV files in MOGRTS, any tips would be appreciated. Thanks again Creative Cows everywhere!
Reply to this Discussion! Login or Sign Up