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

  • Expression to select and affect specific characters in a text

    Posted by Enrique Rovira on June 2, 2015 at 10:23 am

    Ok so I have been trying to find this all over the internet but no luck so far.

    I am trying to create an expression in a text layer so that a specific character is found in the text, like this bullet point: • (alt+8), a different colour is applied.

    Any ideas?

    Thx, E

    Jan Vork replied 4 years, 2 months ago 5 Members · 14 Replies
  • 14 Replies
  • Dan Ebberts

    June 2, 2015 at 4:46 pm

    Try this.

    Add a Fill Color Animator and set the color for the special character.

    Add an Expression Selector.

    Delete the Range Selector.

    Replace the Amount expression in the Expression Selector with this:

    myChar = “•”;
    if (text.sourceText[textIndex-1] == myChar) 100 else 0

    Dan

  • Enrique Rovira

    June 2, 2015 at 5:51 pm

    Thanks Dan, worked beautifully!

  • Enrique Rovira

    June 3, 2015 at 8:28 am

    Actually I came across a problem, for some reason it selects the correct character on the first line but then selects and modifies the colour of the second character on the second line, the third character on the third line, and so on. Of course the bullet point is always the first character on each line.

  • Enrique Rovira

    June 3, 2015 at 8:53 am

    We tried moving things around as below, but to no use!

    myChar = text.sourceText.value[textIndex-1];
    if (myChar === "•") { 100 } else { 0 };

  • Enrique Rovira

    June 3, 2015 at 9:07 am

    We also tried this expression, from another of your posts actually.

    But we get to the exact same problem, on each line will select a further character… If I put everything in one single line it works fine though.

    c = text.sourceText.value[textIndex-1];
    if (/^\•/i.test(c)) 100 else 0

  • Dan Ebberts

    June 3, 2015 at 4:02 pm

    Try it this way:


    txt = text.sourceText.replace(/\r?\n|\r/g,'');
    myChar = "•";
    if (txt[textIndex-1] == myChar) 100 else 0

    Dan

  • Enrique Rovira

    June 3, 2015 at 4:23 pm

    Ok now THAT worked perfect! I’m tinkering with it now but it seems all is fine.

    Thanks!

  • Nathan Clark

    February 11, 2019 at 7:58 am

    Hi there, I was hoping to get this setup working today but sadly it fails… is this because of the new expression engine? would it be possible to get some guidance on getting this to work in AE 16.0.1? Thanks in advance 🙂

  • Dan Ebberts

    February 11, 2019 at 2:10 pm

    This should work:

    txt = text.sourceText.replace(/\r?\n|\r/g,”);
    myChar = “•”;
    txt[textIndex-1] == myChar ? 100 : 0

    Dan

  • Nathan Clark

    February 11, 2019 at 10:28 pm

    Indeed, it works beautifully. Thanks for taking the time to share your knowledge, it is deeply appreciated.

Page 1 of 2

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