Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression to select and affect specific characters in a text

  • Balazs Kun

    February 18, 2019 at 11:01 am

    Hello!

    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 pm

    Something 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

  • Balazs Kun

    February 19, 2019 at 8:02 am

    Perfect.
    Thank You!

  • Jan Vork

    March 8, 2022 at 8:58 am

    Add accolades to avoid a syntax error:

    txt = text.sourceText.replace(/\r?\n|\r/g,”);

    myChar = “:”;

    if (txt[textIndex-1] == myChar) {100} else {0};

Page 2 of 2

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy