Nodejs String Trim trim()

Here you can find the source of trim()

Method Source Code

String.prototype.trim = function() {
   // skip leading and trailing whitespace
   // and return everything in between
   var x=this;/*from w w  w .  j av  a2  s  .c  o m*/
   x=x.replace(/^\s*(.*)/, "$1");
   x=x.replace(/(.*?)\s*$/, "$1");
   return x;
}

Related

  1. trim()
    String.prototype.trim = function() {
      return this.replace(/^\s+|\s+$/g, "");
    };
    
  2. trim()
    'use strict';
    String.prototype.trim = function(){
        return this.replace(/(^\s*)|(\s*$)/g, "");
    
  3. trim()
    String.prototype.trim = function()
    return this.replace(/(^\s*)|(\s*$)/g, "");
    
  4. trim()
    String.prototype.trim = function(){
      var str = this.replace(/\s+/g,"")
      return this;
    
  5. trim()
    $(document).ready(function(){
    });
    String.prototype.trim = function() {
        return this.replace(/(^\s*)|(\s*$)/g, '');
    
  6. 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+$/,"");
    };
    ...
    
  7. trim()
    String.prototype.trim=function(){
      trimLeft = /^\s+/;
      trimRight = /\s+$/;
      return this.replace(trimLeft,"").replace(trimRight,"");
    };
    
  8. trim()
    String.prototype.trim = String.prototype.trim || (String.prototype.trim = function() {
      return this.replace(/^[ ]+|[ ]+$/g, "");
    });
    
  9. trim()
    function cutFixedNum(value,num){
      var value_str = "" + value;
      var index = value_str.indexOf('.');
      if (index!=-1){
        value_str = value_str.substring(0,index+num+1);
      return value_str;
    String.prototype.trim = function() 
    ...