/**
package util{
import flash.utils.ByteArray;
public class StringUtil{
//忽略大小字母比较字符是否相等;
public static function equalsIgnoreCase(char1:String,char2:String):Boolean{
return char1.toLowerCase() == char2.toLowerCase();
}
//比较字符是否相等;
public static function equals(char1:String,char2:String):Boolean{
return char1 == char2;
}
//是否为Email地址;
public static function isEmail(char:String):Boolean{
if(char == null){
return false;
}
char = trim(char);
var pattern:RegExp = /(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/;
var result:Object = pattern.exec(char);
if(result == null) {
return false;
}
return true;
}
//是否是数值字符串;
public static function isNumber(char:String):Boolean{
if(char == null){
return false;
}
return !isNaN(Number(char));
}
//是否为Double型数据;
public static function isDouble(char:String):Boolean{
char = trim(char);
var pattern:RegExp = /^[-\+]?\d+(\.\d+)?$/;
var result:Object = pattern.exec(char);
if(result == null) {
return false;
}
return true;
}
//Integer;
public static function isInteger(char:String):Boolean{
if(char == null){
return false;
}
char = trim(char);
var pattern:RegExp = /^[-\+]?\d+$/;
var result:Object = pattern.exec(char);
if(result == null) {
return false;
}
return true;
}
//English;
public static function isEnglish(char:String):Boolean{
if(char == null){
return false;
}
char = trim(char);
var pattern:RegExp = /^[A-Za-z]+$/;
var result:Object = pattern.exec(char);
if(result == null) {
return false;
}
return true;
}
//中文;
public static function isChinese(char:String):Boolean{
if(char == null){
return false;
}
char = trim(char);
var pattern:RegExp = /^[\u0391-\uFFE5]+$/;
var result:Object = pattern.exec(char);
if(result == null) {
return false;
}
return true;
}
//双字节
public static function isDoubleChar(char:String):Boolean{
if(char == null){
return false;
}
char = trim(char);
var pattern:RegExp = /^[^\x00-\xff]+$/;
var result:Object = pattern.exec(char);
if(result == null) {
return false;
}
return true;
}
//含有中文字符
public static function hasChineseChar(char:String):Boolean{
if(char == null){
return false;
}
char = trim(char);
var pattern:RegExp = /[^\x00-\xff]/;
var result:Object = pattern.exec(char);
if(result == null) {
return false;
}
return true;
}
//注册字符;
public static function hasAccountChar(char:String,len:uint=15):Boolean{
if(char == null){
return false;
}
if(len < 10){
len = 15;
}
char = trim(char);
var pattern:RegExp = new RegExp("^[a-zA-Z0-9][a-zA-Z0-9_-]{0,"+len+"}$", "");
var result:Object = pattern.exec(char);
if(result == null) {
return false;
}
return true;
}
//URL地址;
public static function isURL(char:String):Boolean{
if(char == null){
return false;
}
char = trim(char).toLowerCase();
var pattern:RegExp = /^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/;
var result:Object = pattern.exec(char);
if(result == null) {
return false;
}
return true;
}
// 是否为空白;
public static function isWhitespace(char:String):Boolean{
switch (char){
case " ":
case "\t":
case "\r":
case "\n":
case "\f":
return true;
default:
return false;
}
}
//去左右空格;
public static function trim(char:String):String{
if(char == null){
return null;
}
return rtrim(ltrim(char));
}
//去左空格;
public static function ltrim(char:String):String{
if(char == null){
return null;
}
var pattern:RegExp = /^\s*/;
return char.replace(pattern,"");
}
//去右空格;
public static function rtrim(char:String):String{
if(char == null){
return null;
}
var pattern:RegExp = /\s*$/;
return char.replace(pattern,"");
}
//是否为前缀字符串;
public static function beginsWith(char:String, prefix:String):Boolean{
return (prefix == char.substring(0, prefix.length));
}
//是否为后缀字符串;
public static function endsWith(char:String, suffix:String):Boolean{
return (suffix == char.substring(char.length - suffix.length));
}
//去除指定字符串;
public static function remove(char:String,remove:String):String{
return replace(char,remove,"");
}
//字符串替换;
public static function replace(char:String, replace:String, replaceWith:String):String{
return char.split(replace).join(replaceWith);
}
//utf16转utf8编码;
public static function utf16to8(char:String):String{
var out:Array = new Array();
var len:uint = char.length;
for(var i:uint=0;i<len;i++){
var c:int = char.charCodeAt(i);
if(c >= 0x0001 && c <= 0x007F){
out[i] = char.charAt(i);
} else if (c > 0x07FF) {
out[i] = String.fromCharCode(0xE0 | ((c >> 12) & 0x0F),
0x80 | ((c >> 6) & 0x3F),
0x80 | ((c >> 0) & 0x3F));
} else {
out[i] = String.fromCharCode(0xC0 | ((c >> 6) & 0x1F),
0x80 | ((c >> 0) & 0x3F));
}
}
return out.join('');
}
//utf8转utf16编码;
public static function utf8to16(char:String):String{
var out:Array = new Array();
var len:uint = char.length;
var i:uint = 0;
var char2:int,char3:int;
while(i<len){
var c:int = char.charCodeAt(i++);
switch(c >> 4){
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
// 0xxxxxxx
out[out.length] = char.charAt(i-1);
break;
case 12: case 13:
// 110x xxxx 10xx xxxx
char2 = char.charCodeAt(i++);
out[out.length] = String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
break;
case 14:
// 1110 xxxx 10xx xxxx 10xx xxxx
char2 = char.charCodeAt(i++);
char3 = char.charCodeAt(i++);
out[out.length] = String.fromCharCode(((c & 0x0F) << 12) |
((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0));
break;
}
}
return out.join('');
}
//转换字符编码;
public static function encodeCharset(char:String,charset:String):String{
var bytes:ByteArray = new ByteArray();
bytes.writeUTFBytes(char);
bytes.position = 0;
return bytes.readMultiByte(bytes.length,charset);
}
//添加新字符到指定位置;
public static function addAt(char:String, value:String, position:int):String {
if (position > char.length) {
position = char.length;
}
var firstPart:String = char.substring(0, position);
var secondPart:String = char.substring(position, char.length);
return (firstPart + value + secondPart);
}
//替换指定位置字符;
public static function replaceAt(char:String, value:String, beginIndex:int, endIndex:int):String {
beginIndex = Math.max(beginIndex, 0);
endIndex = Math.min(endIndex, char.length);
var firstPart:String = char.substr(0, beginIndex);
var secondPart:String = char.substr(endIndex, char.length);
return (firstPart + value + secondPart);
}
//删除指定位置字符;
public static function removeAt(char:String, beginIndex:int, endIndex:int):String {
return StringUtil.replaceAt(char, "", beginIndex, endIndex);
}
//修复双换行符;
public static function fixNewlines(char:String):String {
return char.replace(/\r\n/gm, "\n");
}
}
}
分享到:
相关推荐
api-ms-win-core-util-l1-1-0.dll api-ms-win-crt-conio-l1-1-0.dll api-ms-win-crt-convert-l1-1-0.dll api-ms-win-crt-environment-l1-1-0.dll api-ms-win-crt-filesystem-l1-1-0.dll api-ms-win-crt-heap-l1-1-0....
import java.util.Hashtable; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import com.ejb.HelloWorldRemote; public class ClientTest { /** * @...
6. **字符串处理**:`com.adobe.utils.StringUtil`提供了一些字符串操作的便利方法,比如URL编码解码、HTML转义等。 7. **网络请求**:虽然AS3有URLLoader类,但as3corelib提供了HTTPService类,使得网络请求更加...
这是因为在AS3中,你可以直接访问对象并进行操作,而在AS2中则较为复杂。 2. **UIComponent的继承**: - 若要将Flash内容直接整合到Flex项目中,你需要确保类继承自UIComponent。这与Flash中的DisplayObject类类似...
- 示例:`PopUpManager`、`MouseEvent`、`StringUtil`等 - 类型:当存在歧义时,使用Type后缀以区分不同的功能角色。 3. **接口** - 范式:`ISealedName[Type]` - 示例:`IController`、`IDataModel` - 接口...
### Flex + AS3编程规范详解 #### 一、编码规范概览 在Flex与AS3的编程环境中,遵循一套统一的编码规范对于提高代码的可读性和可维护性至关重要。以下将详细介绍Flex + AS3编程规范中涉及的关键知识点,包括缩写...
在Android源码树中添加userspace I2C读写工具(i2c-util) 本文使用的开发板是:杭州若格科技有限公司的全志R8。CPU:CPUARM Cortex-A8 更多芯片资料请参见全志官网: http://www.allwinnertech.com/clq/r/R8.html...
9. **字符串操作**:`com.adobe.utils.StringUtil` 类包含了一些字符串处理的辅助函数,如比较、截取、替换等。 10. **数学运算**:`com.adobe.math` 命名空间包含了一些数学相关的辅助类,例如`Matrix3D` 和 `...
sb.Append(StringUtil.ReplaceSpecialChars(model.StartTime + "")).Append(","); sb.Append(StringUtil.ReplaceSpecialChars(model.TraceStart + "")).Append(","); sb.Append(StringUtil.ReplaceSpecialChars...
#### 3. AS项目多渠道混淆打包 **3.1 生成签名文件就不多说,同上** **3.2 添加签名文件(步骤如下)** - **配置签名信息**:在`build.gradle`文件中添加签名信息。这通常是在项目的根目录下的`build.gradle`文件中...
As of version 2.1, use encodeRedirectURL(String url) instead encodeRedirectURL(String) - Method in class javax.servlet.http.HttpServletResponseWrapper The default behavior of this method is to ...
� 良好的盈利模式( 3/7 开),产业链条的各方:运营商、制造商、独立软件生产商都可以获得不错的利 益 。 将移动终端的评价标准从硬件向软件转变,极大的激发了软件开发者的热情。 � Android 的源代码遵循 Apache...
.- Reduced the line sleep to 30 (tell me if this value doesn‘t work for you).27/4/981.7.0- Fixed a memory leak, thanks to Don Higgins.- Moved the string esErrorInFormatOfMsg to a property of SakPOP.-...
(Please see UTIL.DOC for details.) NEW BGI FONTS ------------- Several new fonts have been added to the Borland Graphics Interface: Name Value Description ---------------------------------------...