w3c substr()的解釋:
Extracts the characters from a string, beginning at a specified start position, and through the specified number of character.
簡單的講就是,指定開始位置與需要的長度抽取出子字串。index從0開始。
Extracts the characters from a string, beginning at a specified start position, and through the specified number of character.
簡單的講就是,指定開始位置與需要的長度抽取出子字串。index從0開始。
語法:
"somestring".substr(start, length)
"somestring".substr(start, length)
例子:
alert("12345".substr(2,3)); //會印出345
alert("12345".substr(2,3)); //會印出345
w3c substring()的解釋:
Extracts the characters from a string, between two specified indices.
substring()則是抽取出兩個index之間的子字串。index從0開始。
Extracts the characters from a string, between two specified indices.
substring()則是抽取出兩個index之間的子字串。index從0開始。
語法:
"something".substring(from, to)
"something".substring(from, to)
例子:
alert("12345".substring(2,3)); //會印出3
alert("12345".substring(2,3)); //會印出3
沒有留言:
張貼留言