Skip to content

Commit abcca46

Browse files
committed
清除空格
1 parent 6626a24 commit abcca46

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Diff for: trim.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @description 清除空格
3+
* @author 未知
4+
*/
5+
6+
String.prototype.trim = function() {
7+
var reExtraSpace = /^\s*(.*?)\s+$/;
8+
return this.replace(reExtraSpace, "$1")
9+
}
10+
11+
// 清除左空格
12+
function ltrim(s){ return s.replace( /^(\s*| *)/, ""); }
13+
14+
// 清除右空格
15+
function rtrim(s){ return s.replace( /(\s*| *)$/, ""); }

0 commit comments

Comments
 (0)