Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › “if source text has some of these characters then” type of expression

  • “if source text has some of these characters then” type of expression

    Posted by Vlad Krylevskyi on January 27, 2021 at 7:43 pm

    Let’s say I want to make the opacity of some shape layer to depend on the specific characters in some other text layer, something like “if this source text contains any of A, L, Z, Y, or Q, then make opacity 100, if not 20”.

    Is there a way to do that? Thanks!

    Vlad Krylevskyi replied 5 years, 7 months ago 3 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    January 27, 2021 at 8:18 pm

    Maybe something like this:

    txt = thisComp.layer("text").text.sourceText;

    txt.toUpperCase().match(/A|L|Z|Y|Q/) ? 100 : 20

  • Kim Tae Kyun

    January 28, 2021 at 5:10 am

    Regex(Regular expression) is good way to do this kind of work, but if your text is long, after effect calculation get slower.. unfortunately

  • Vlad Krylevskyi

    February 3, 2021 at 6:57 pm

    That worked exactly how I wanted, thanks Dan! I replaced “:” and “?” with “if…else if…else” and was able to set up multiple statements. But I got a problem with special symbols, like comas, brackets. Is there a way to put them in this line along with my letters?

  • Vlad Krylevskyi

    February 3, 2021 at 7:01 pm

    oh, I think I found the answer myself. I just put \ right before it

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