如果字母 > 在 AS3 中为 10,则拆分
Split if letters > at 10 in AS3
我正在尝试拆分包含超过 10 个字母的每个单词。
我该怎么办?
我做到了:
if (item.title.length > 10){
trace("item.length>10");
// What should I put here in order to erase the letters after the 10th one ?
}
if (item.title.length > 10){
trace("item.length>10"); // 0
trace(String(item.title).substring(0,10)); // if item.title is "star wars : the force" it will shows "star wars "
var arr:Array=String(item.title).split("");
for(var i:int=0;i<arr.length;i++)
{
trace(arr[i]);// it shows every letter in the array
}
}
var string0:String = 'hello';
var string1:String = 'hello this is a test string';
// trunkate to up to 10 chars...
string0 = string0.slice(0, 10);
string1 = string1.slice(0, 10);
trace('>' + string0 + '<'); // result is >hello<
trace('>' + string1 + '<'); // result is >hello this<
我正在尝试拆分包含超过 10 个字母的每个单词。
我该怎么办?
我做到了:
if (item.title.length > 10){
trace("item.length>10");
// What should I put here in order to erase the letters after the 10th one ?
}
if (item.title.length > 10){
trace("item.length>10"); // 0
trace(String(item.title).substring(0,10)); // if item.title is "star wars : the force" it will shows "star wars "
var arr:Array=String(item.title).split("");
for(var i:int=0;i<arr.length;i++)
{
trace(arr[i]);// it shows every letter in the array
}
}
var string0:String = 'hello';
var string1:String = 'hello this is a test string';
// trunkate to up to 10 chars...
string0 = string0.slice(0, 10);
string1 = string1.slice(0, 10);
trace('>' + string0 + '<'); // result is >hello<
trace('>' + string1 + '<'); // result is >hello this<