Working with Substring Values: substr : substr « String « Flash / Flex / ActionScript






Working with Substring Values: substr

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){

        var sTitle:String = new String("ActionScript Bible");
        trace(sTitle.substr(6, 6));  // Displays: Script
        trace(sTitle.substr(0, 6));  // Displays: Action
        trace(sTitle.substr(0, 12)); // Displays: ActionScript

    }
  }
}

        








Related examples in the same category

1.Optionally omit the second parameter, substr returns a substring starting at the specified index and going to the end of the original string.
2.Specifying a negative value simply counts backward from the end of the string where -1 is the last character.
3.substring method returns a substring starting with the starting index specified and containing all the characters up to, but not including, the ending index.
4.Use lastIndexOf to get the file name without extension name