Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Find specific characters in text and apply position offset

  • Find specific characters in text and apply position offset

    Posted by Franck Michel on September 14, 2024 at 1:56 am

    Hi everyone,

    I’m trying to do a basic thing but can’t find how.

    I want to scan a text layer for specific characters like p, q, j, y and then apply an offset position if one of them is present.

    For now I found an expression that works very well for one character but I am not able to tell it to search for multiple ones.

    var txt = thisComp.layer("WORDING").text.sourceText;
    var myChar = "w";
    var yOffset= txt.includes(myChar) ? 15 : 0;
    value + [0, yOffset];

    I tried every syntax where the “w” is in the myChar variable but can’t seem to make it work.

    Brie Clayton
    replied 1 month ago
    3 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    September 14, 2024 at 7:00 am

    I’m not sure if this is what you’re asking, but maybe:

    txt = thisComp.layer("WORDING").text.sourceText;
    yOffset = (txt.includes("p") || txt.includes("q") || txt.includes("j") || txt.includes("y")) ? 15 : 0;
    value + [0,yOffset]
  • Franck Michel

    September 14, 2024 at 7:33 am

    Thank you so much Dan this is perfect and works like a charm.

    I would never have thought of this in a million years, and was too stubborn to try a repetition of the condition like you did.

  • Brie Clayton

    September 14, 2024 at 8:52 am

    Thank you for solving this, Dan!

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