2012-04-03 7 views
1

私はこのようなActionScriptで文字のグループに分割さ文字列が必要です。howtoは、文字列をactionscriptの文字グループに分割しますか?

var txt:String = "Hello World"; 
var arr:Array = txt.split(3); 
// Now arr should contain a value like: ["Hel", "lo ", "Wor", "ld"] 

をこれは、このようにPHPで可能です:

$arr = str_split(txt, 3); 

しかし、私はこのPHPコードのActionScriptの同等物を必要とします。

答えて

3

あなたは正規表現を使用することができます

var txt:String = "Hello World"; 
var arr:Array = txt.match(/.{3}|.+/g); 
trace(arr); 
// Hel,lo ,Wor,ld