Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How to remove the first three characters from a string and display the rest?

  • How to remove the first three characters from a string and display the rest?

    Posted by Dave Martin on September 2, 2012 at 2:54 pm

    Hi All,

    I’m making a score sheet to display: Position and Runner Name.

    There is a main Comp called “Event_Name” and within this there are several Comps called:
    “01 Runner Name”
    “02 Runner Name”
    “03…”

    So for I’ve got the position and the runner name to show, See below

    the_place = comp(“Event_Name”).layer(thisComp.name).index;
    the_name = comp(“Event_Name”).layer(thisComp.name).name ;
    divider = ” ” ;
    the_place + divider + the_name

    In line [2] the name of the comp is what I want to be displayed. However, in order to keep these layers in order in the project window and the “Event_Name” comp I have to name them as such:
    01 Runner Name
    02 Runner Name
    03…

    What I need to do in line [4] is just display the ‘Runner Name’ but without the first 3 characters I.E. “01 “.
    So I need to remove the first 3 characters and display the rest – NOTE: Comp Names are all different lengths 🙁

    Cheers,

    Dave.

    Dave Martin replied 13 years, 9 months ago 2 Members · 2 Replies
  • 2 Replies
  • Xavier Gomez

    September 2, 2012 at 3:49 pm

    Strings have a slice method: .slice(m,n)
    It removes the first m characters, keeps m-n, and removes the rest.
    the second parameter is optionnal so if n is not specified, .slice(m) removes the first m characters and keeps the rest.

    so maybe you can replace line[4] by

    the_place + divider + the_name.slice(3)

    —–

    Xavier

  • Dave Martin

    September 3, 2012 at 4:00 am

    PERFECT!!! EXACTLY WHAT I NEEDED!

    Thank you Soooooo Much Xavier

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