JS 去掉空格

Trim() 去掉前後空格

LTrim() 去掉前空格

RTrim() 去掉後空格

TrimAll() 去掉所有空格

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, "");
}

Strin.prototype.TrimAll = function()

{

 return this.replace(/( )/g,"")
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章