?? stringutils.as
字號:
/*Copyright (c) 2006 Adobe Systems Incorporated
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
package qs.utils
{
public class StringUtils
{
public static function trim(value:String):String
{
return value.match(/^\s*(.*?)\s*$/)[1];
}
public static function replaceAll(input:String, replace:String, replaceWith:String):String{
if(input == null){
return "";
}else{
input = new String(input);
var s:Number = 0;
s = input.search(replace);
var t:String;
while(input.indexOf(replace) >= 0){
t = input.replace(replace, replaceWith);
input = t
}
return input;
}
}
/*public static function replaceAll(input:String, replace:String, replaceWith:String):String
{
//change to StringBuilder
var sb:String = new String();
var found:Boolean = false;
var sLen:Number = input.length;
var rLen:Number = replace.length;
for (var i:Number = 0; i < sLen; i++)
{
if(input.charAt(i) == replace.charAt(0))
{
found = true;
for(var j:Number = 0; j < rLen; j++)
{
if(!(input.charAt(i + j) == replace.charAt(j)))
{
found = false;
break;
}
}
if(found)
{
sb += replaceWith;
i = i + (rLen - 1);
continue;
}
}
sb += input.charAt(i);
}
//TODO : if the string is not found, should we return the original
//string?
return sb;
}*/
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -