Nodejs String Trim trim()

Here you can find the source of trim()

Method Source Code

/* Copyright(c) 2003-2007 Wang, Chun-Pin All rights reserved.
 *
 * Version:   $Id: misc.js,v 1.2 2008/11/30 03:46:28 alex Exp $
 *
 */// ww  w.j  av  a  2 s .co  m
var Firefox = (document.getElementById && !document.all);
var MSIE = (-1 != navigator.userAgent.indexOf('MSIE'));

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

function Redirect(url)
{
   parent.location=url;
}

var Submitted = 0;
function OnSubmit(form)
{
   if (Submitted) {
      return false;
   }
   Submitted = 1;
   return true;
}

Related

  1. trim()
    String.prototype.trim = function() {
      var re = /^\s+|\s+$/g;
      return this.replace(re, "");
    
  2. trim()
    String._trimRE = new RegExp().compile(/^\s+|\s+$/g);
    String.prototype.trim = function()
      return this.replace(String._trimRE, "");
    
  3. trim()
    String.prototype.trim = function() {
        return this.replace(/^\s*/, "").replace(/\s*$/, "");
    };
    
  4. trim()
    console.log("'" + " a ".trim() + "'");
    String.prototype.trim = function(){
      return this.replace(/^\s+|\s+$/g, '');
    };    
    console.log("'" + " b ".trim() + "'");
    
  5. trim()
    String.prototype.trim = function()
      var x=this;
      x=x.replace(/^\s*(.*)/, "$1");
      x=x.replace(/(.*?)\s*$/, "$1");
      return x;
    
  6. trim()
    String.prototype.trim = function(){ 
      return this.rTrim(this.lTrim());
    
  7. trim()
    String.prototype.trim = String.prototype.trim || function () {
      const
        str = this.replace(/^\s\s*/, '');
      let
        i = str.length;
      for (let rgxp = /\s/; rgxp.test(str.charAt(--i));) {
      return str.substring(0, i + 1);
    };
    ...
    
  8. trim()
    'use strict';
    Array.isArray = Array.isArray || function (obj) {
      return {}.call(obj) === '[object Array]';
    };
    String.prototype.trim = String.prototype.trim || function () {
      const
        str = this.replace(/^\s\s*/, '');
      let
        i = str.length;
    ...
    
  9. trim()
    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,"");