Activity › Forums › Adobe After Effects Expressions › Expression to select and affect specific characters in a text
-
Expression to select and affect specific characters in a text
Jan Vork replied 4 years, 2 months ago 5 Members · 14 Replies
-
Balazs Kun
February 18, 2019 at 11:01 amHello!
It works fine and thanks for sharing this code.
How could I select multiple characters? For example I want to select all “a” and “e” letters from a string.
I tried use an array but didn’t work.Thanks!
-
Dan Ebberts
February 18, 2019 at 7:15 pmSomething like this should work:
txt = text.sourceText.replace(/\r?\n|\r/g,'');
myChars = "ae";
result = 0;
for (i = 0; i < myChars.length; i++){
if (txt[textIndex-1] == myChars[i]){
result = 100;
break;
}
}
result
Dan
-
Jan Vork
March 8, 2022 at 8:58 amAdd accolades to avoid a syntax error:
txt = text.sourceText.replace(/\r?\n|\r/g,”);
myChar = “:”;
if (txt[textIndex-1] == myChar) {100} else {0};
Reply to this Discussion! Login or Sign Up