Nodejs String Trim trim()

Here you can find the source of trim()

Method Source Code

$(document).ready(function(){

});//w w w.j a  va 2  s.  c om


String.prototype.trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, '');
}

Related

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