Trim Function in JavaScript |
|
|
2004-10-14 11:19:03 |
|
TrimAll()
{
var objRegExp = /^(\s*)$/;
// Check for all spaces
if (objRegExp.test(strValue))
{
strValue = strValue.replace(objRegExp, '');
if( strValue.length == 0)
return strValue;
}
// Check for leading & trailing spaces
objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
if (objRegExp.test(strValue))
{
//remove leading and trailing whitespace characters
strValue = strValue.replace(objRegExp, '$2');
}
return strValue;
}
|
| 内容为网上收集,并不代表本站同意或者赞同其观点,如果有任何版权,内容问题,请联系本站,我们将在第一时间处理. |
|
|
|