Nodejs String Trim trim()

Here you can find the source of trim()

Method Source Code

String.prototype.trim = function(){
   /*from  www. j av a2 s. co m*/
   var str = this.replace(/\s+/g,"")
   return this;
}

Related

  1. trim()
    String.prototype.trim = function() {
        try {
            return this.replace(/^\s+|\s+$/g, "");
        } catch(e) {
            return this;
    };
    
  2. trim()
    String.prototype.trim = function() {
        return this.replace(/^[ ]+|[ ]+$/g, '');
    };
    
  3. trim()
    String.prototype.trim = function() {
      return this.replace(/^\s+|\s+$/g, "");
    };
    
  4. trim()
    'use strict';
    String.prototype.trim = function(){
        return this.replace(/(^\s*)|(\s*$)/g, "");
    
  5. trim()
    String.prototype.trim = function()
    return this.replace(/(^\s*)|(\s*$)/g, "");
    
  6. trim()
    $(document).ready(function(){
    });
    String.prototype.trim = function() {
        return this.replace(/(^\s*)|(\s*$)/g, '');
    
  7. trim()
    String.prototype.trim = function() {
      var x=this;
      x=x.replace(/^\s*(.*)/, "$1");
      x=x.replace(/(.*?)\s*$/, "$1");
      return x;
    
  8. trim()
    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+$/,"");
    };
    ...
    
  9. trim()
    String.prototype.trim=function(){
      trimLeft = /^\s+/;
      trimRight = /\s+$/;
      return this.replace(trimLeft,"").replace(trimRight,"");
    };