Nodejs String Trim trim()

Here you can find the source of trim()

Method Source Code

function $(e){//from  w ww  .ja  va2s.co  m
   return document.getElementById(e);
}

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

function checkFormField(fieldObj,msgObj,re,nullMsg,errorMsg){
   msgObj.innerHTML = "";
   var v = fieldObj.value.replace(/(^\s+)|(\s+$)/g,"");
   var flag = true;
   if(v.length==0){
      msgObj.innerHTML = nullMsg;
      flag = false;
   } else{
      if(!(re.test(v))){
         msgObj.innerHTML = errorMsg;
         flag = false;
      }
   }
   return flag;
}

Related

  1. trim()
    String.prototype.trim = function(){ 
      return this.rTrim(this.lTrim());
    
  2. 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);
    };
    ...
    
  3. 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;
    ...
    
  4. 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,"");
    
  5. trim()
    var person = {};
    person.say = function(name){
        console.log(name);
    };
    person.say("lilei");
    String.prototype.trim = function(){
        return this.replace(/(^\s*)|(\s*$)/g, "");
    function  trim(str){
    ...
    
  6. trim()
    String.prototype.trim = function()
      return this.replace(/^\s*/, "").replace(/\s*$/, "");
    
  7. trim()
    String.prototype.trim = String.prototype.trim || function(){
      if (!this) return this;
      return this.replace(/^\s+|\s+$/g, "");
    
  8. trim()
    String.prototype.trim = function() {
      return this.replace(/^\s+/, '').replace(/\s+$/, '');
    };
    
  9. trim()
    String.prototype.trim = function() {
      return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');