遇到什么补充什么:
字符串换行: \n
字符串空格:\t
\b Backspace字符(ASCII 8)
\f 走纸换页字符(ASCII 12)
\n 换行字符(ASCII 10)
\r 回车自负(ASCII 13)
\t 制表符(Tab)(ASCII 9)
\” 双引号
\’; 单引号
\\ 反斜线符号(\)
\000~\377 一个用8进制指定的字符(占一个字节)
\x00~\xFF 一个用16进制指定的字符(占一个字节)
\u0000~\uFFFF 一个用16进制指定的Unicode字符(占两个字符)
输出:
13
0
she is a girl
is
i
i
rl
rl
She is a girl
0
She,is
object
true
false
false
AS3 code:
package { import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; public class Main extends Sprite { var str:String = "She is a girl"; public function Main():void { stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; Init(); } private function Init() { var len:int = str.length; trace(len); var num1:int = str.indexOf("She"); trace(num1); trace("she".concat(str.slice((num1+3)))); trace(str.substr(4,2)); trace(str.substring(4,5)); trace(str.slice(4,5)); trace(str.substr(-2)); trace(str.slice(-2)); trace(str.substring(-2)); trace(str.search("She")); trace(str.split(" ",2)); trace(typeof(str.split(" ",100))); trace(typeof(str.split(" ",100)) is Object); trace(typeof(str.split(" ",100)) is Array); trace((typeof(str.split(" ",100)) as Array) is Array); } } }