Here you can find the source of trim()
/**//from w ww . j a v a 2s.c o m * 018_trim_a_string.js * http://www.codewars.com/kata/trim-a-string/train/javascript * * Sjaak van den Berg * https://www.twitter.com/svdb */ /** * Extend the String prototype by a `trim` function, that returns the string * with leading or trailing whitespaces removed. */ String.prototype.trim = function() { return this.replace(/^\s+/, '').replace(/\s+$/, ''); };
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,""); function trim(str){ return str.replace(/(^\s*)|(\s*$)/g, ""); function ltrim(str){ return str.replace(/(^\s*)/g,""); function rtrim(str){ return str.replace(/(\s*$)/g,"");
var person = {}; person.say = function(name){ console.log(name); }; person.say("lilei"); String.prototype.trim = function(){ return this.replace(/(^\s*)|(\s*$)/g, ""); function trim(str){ ...
function $(e){ return document.getElementById(e); String.prototype.trim = function(){ return this.replace(/(^\s+)|(\s+$)/g,""); function checkFormField(fieldObj,msgObj,re,nullMsg,errorMsg){ msgObj.innerHTML = ""; var v = fieldObj.value.replace(/(^\s+)|(\s+$)/g,""); ...
String.prototype.trim = function() return this.replace(/^\s*/, "").replace(/\s*$/, "");
String.prototype.trim = String.prototype.trim || function(){ if (!this) return this; return this.replace(/^\s+|\s+$/g, "");
String.prototype.trim = function() { return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
String.prototype.trim = function() { return this.replace(/^s+|s+$/, ?);
function trim(stringToTrim) { return stringToTrim.replace(/^\s+|\s+$/g,""); function ltrim(stringToTrim) { return stringToTrim.replace(/^\s+/,""); function rtrim(stringToTrim) { return stringToTrim.replace(/\s+$/,""); String.prototype.trim = function() {return this.replace(/^\s+|\s+$/g,"");} String.prototype.ltrim = function() {return this.replace(/^\s+/,"");} String.prototype.rtrim = function() {return this.replace(/\s+$/,"");}
String.prototype.trim = function(){ if(/^([ | ]*)(.*)([ | ]*)$/.test(this)){ return RegExp.$2; return this; };