<script language=javascript>
//去全部空格
String.prototype.trim = function(){
return this.replace(/(^/s*)|(/s*$)/g, "");
}
//去左边空格
String.prototype.ltrim = function(){
return this.replace(/(^/s*)/g, "");
}
//去右边空格
String.prototype.rtrim = function(){
return this.replace(/(/s*$)/g, "");
}
//验证是否为不带小数点正整数
String.prototype.isPositiveInteger = function(){
return /^/+?/d+$/.exec( this )
}
//验证是否为不带小数点负整数
String.prototype.isNegativeInteger = function(){
return /^/-?/d+$/.exec( this )
}
//验证是否为整数(不带小数点)
String.prototype.isInteger = function(){
return /^(/-|/+)?/d+$/.exec( this )
}
//验证是否为整数 正数
String.prototype.isPositiveDecimal = function(){
return /^/+?/d+(/./d+)?$/.exec( this )
}
//验证是否为整数 负数
String.prototype.isNegativeDecimal = function(){
return /^/-/d+(/./d+)?$/.exec( this )
}
//验证是否为整数 (带小数点)
String.prototype.isDecimal = function(){
return /^(/-|/+)?/d+(/./d+)?$/.exec( this )
}
//验证是否为大写字母
String.prototype.isCapital = function(){
return /^[A-Z]+$/.exec( this )
}
//验证是否为小写字母
String.prototype.isLowercase = function(){
return /^[a-z]+$/.exec( this )
}
//合并字符串
function StringBuffer(){
this._strings_ = new Array;
StringBuffer.prototype.append = function( str ){
this._strings_.push( str );
}
StringBuffer.prototype.tostring = function(){
return this._strings_.join( "" );
}
}
</script>
未完