Nodejs String Trim trim()

Here you can find the source of trim()

Method Source Code

// Trim//from  ww  w.j  a v a  2  s.co m
String.prototype.trim = function () {
   return this.replace(/^\s+|\s+$/g, "");
}

Related

  1. trim(()
    String.prototype.trim = (function() {
      var trimRegex = /(^\s+|\s+$)/g;
      return function() {
        return this.replace(trimRegex, '');
      };
    }());
    
  2. trim(()
    String.prototype.trim = (function() {
            var trimRegex = /(^\s+|\s+$)/g;
            return function() {
                    return this.replace(trimRegex, '');
            };
    
  3. trim()
    String.prototype.trim = function(){
        return this.replace(/(^[\\s]*)|([\\s]*$)/g, "");
    
  4. trim()
    String.prototype.trim = function trim() {
      return this.replace(/^\s+|\s+$/g, '');
    };
    
  5. trim()
    String.prototype.trim = function(){
      return this.replace(/^(\s|\u00A0)+/,'').replace(/(\s|\u00A0)+$/,'');   
    
  6. trim()
    String.prototype.trim = function () {
      return this.replace(/^\s+|\s+$/, "");
    };
    
  7. trim()
    'use strict';
    String.prototype.trim = function(){
      return /^\s*([\d\D]*?)\s*$/.exec(this)[1];
    };
    
  8. trim()
    String.prototype.trim=function(){
      return this.replace(/^\s+|\s+$/g,"");
    
  9. trim()
    String.prototype.trim = function () {
      return this.replace(/^\s+/, ""); 
    };