Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Count the number of characters up until the second incident of a specific char.

  • Count the number of characters up until the second incident of a specific char.

    Posted by Klaus Hertweck on September 22, 2024 at 9:46 pm

    Let’s assume I have this text: “THIS IS MY EXAMPLE TEXT.”

    I want to count the number of characters until the text reaches the second incident of a space. E.g. up to the second space, there are 6 characters in the text.

    I want to use a slider to specify the number of spaces and then use the amount of characters to create a substring.

    Brie Clayton
    replied 2 weeks, 6 days ago
    3 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    September 22, 2024 at 11:46 pm

    Like this maybe:

    s = Math.round(effect("Slider Control")("Slider"));
    txt = value;
    n = 0;
    for (i = 0; i<txt.length; i++){
    if (txt[i] == " "){
    n++;
    if (n == s) break;
    }
    }
    txt.substr(0,i)
  • Klaus Hertweck

    September 23, 2024 at 8:15 am

    Thank you Dan!

    It worked just perfectly!

  • Brie Clayton

    September 23, 2024 at 7:00 pm

    Thanks for solving this, Dan!

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