| 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?
by Dave Martin on Sep 2, 2012 at 2:54:05 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.
| | | | |
• | | | |  | Re: How to remove the first three characters from a string and display the rest? by Xavier Gomez on Sep 2, 2012 at 3:49:23 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
| | | | |
• | | | |  | Re: How to remove the first three characters from a string and display the rest? by Dave Martin on Sep 3, 2012 at 4:00:46 am |
PERFECT!!! EXACTLY WHAT I NEEDED!
Thank you Soooooo Much Xavier
| | | | |
| |
|