substr(starting index,length);
substring(starting index,end index);
note :- all the parameters are numbers.
For substr
- starting index : starting point of extraction (in other words after how many letters)
- length : length of the text that should extracted from the starting point
starting index = 2
length = 5
Then the text getting extracted is “tract”
For substring
- starting index : starting point of extraction
- end index : end point of extraction
starting index = 2
end index = 5
Then the text getting extracted is “tra”
Sample as3 code :
<Code>
// creating a new String called myText and print it
var myText:String = new String("Extracting");
trace(myText); //output: Extracting
//<substr> extracting part of myText to a new variable called extractedText1 and print it
var extractedText1 = myText.substr(2,5);
trace(extractedText1); //output: tract
//<substring> extracting part of myText to a new variable called extractedText1 and print
var extractedText2 = myText.substring(2,5);
trace(extractedText2); //output: tra
No comments:
Post a Comment