Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions detect certain letters in the first row of a text layer

  • detect certain letters in the first row of a text layer

    Posted by Detlef Maerz on December 10, 2021 at 10:24 am

    Hi guys,
    I’m searching for an expression to detect certain letters (Ä,Ö and Ü) in the first row of a text layer and return a boolean.
    Could you help me with the right function and notation?

    Detlef Maerz replied 4 years, 4 months ago 2 Members · 4 Replies
  • 4 Replies
  • Filip Vandueren

    December 10, 2021 at 11:13 am

    Hi Detlef, here’s a method using regular expressions.

    I suppose that with the first Row, you mean the first line that is explicitly ended by a line-break, not a line that is automatically wrapped by a textbox ?

    firstline = thisComp.layer("txt").text.sourceText.split("\r")[0];
    booleanResult = /Ä|Ö|Ü/.test(firstline);
  • Detlef Maerz

    December 10, 2021 at 12:46 pm

    Yes, that’s what I meant. Works perfectly! Thank you very much! One additional question: what should the syntax look like for the last line?

  • Filip Vandueren

    December 10, 2021 at 1:26 pm

    something like this:

    lines = thisComp.layer("txt").text.sourceText.split("\r");
    firstline = lines[0];
    lastline = lines[lines.length-1];
    booleanResult = /Ä|Ö|Ü/.test(lastline);
  • Detlef Maerz

    December 11, 2021 at 3:01 pm

    Thank You, Filip! Really helpful! 👍

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