标签:java os io ar cti javascript on c type
Javascript去掉字符串前后空格
function String.prototype.trim(){
return this.toString().replace(/^\s+|\s+$/g,"");
}
=====================================
<script language=Javascript>
function String.prototype.Trim() {return this.replace(/(^\s*)|(\s*$)/g,"");}
function String.prototype.Ltrim(){return this.replace(/(^\s*)/g, "");}
function String.prototype.Rtrim(){return this.replace(/(\s*$)/g, "");}
var str = " Trim ";
alert(str.Trim());
</script>
=====================================
返回去掉字符串前后逗号的值
onblur=‘this.value=this.value.toString().replace(/(^\,*)|(\,*$)/g,"")‘
标签:java os io ar cti javascript on c type
原文地址:http://www.cnblogs.com/weixing/p/3930813.html