Nodejs String Trim trimString_trim()

Here you can find the source of trimString_trim()

Method Source Code

String.prototype.trim = function String_trim()
  this.replace(/^\s+/m, '').replace(/\s+$/m, '');

Related

  1. trimSlash()
    String.prototype.trimSlash = function () {
        var string = this.trim();
        if (string.charAt(0) == "/") {
            string = string.substring(1);
        if (string.charAt(string.length - 1) == "/") {
            string = string.substring(0, string.length - 1);
        return string;
    ...
    
  2. trimSpace()
    'use strict';
    String.prototype.trimSpace = function() {
        var s = this;
        var n = s.length - 1;
        while (n >= 0 && s.charCodeAt(n) == 32) {
            n--;
        return n >= 0 ? s.substr(0, n + 1) : "";
    };
    ...
    
  3. trimSpaces()
    String.prototype.trimSpaces = function () {
      var phrases = this.split(" ");
      var result = "";
      for (var i = 0; i < phrases.length; i++) {
        if (!phrases[i]=="") {
          if (result=="") {
            result = phrases[i];
          } else {
            result += " " + phrases[i];
    ...
    
  4. trimStart(c)
    String.prototype.trimStart=function(c)
        c = c?c:' ';
        var i=0;
        for(;i<this.length && this.charAt(i)==c; i++);
        return this.substring(i);
    
  5. trimStart(s)
    String.prototype.trimStart = function(s) {
        return this.replace(new RegExp("^" + s + "+", "gm"), "");
    
  6. trimTailChars(c)
    String.prototype.trimTailChars = function(c){
      var idx, len = this.length;
      var tmp = this;
      while(len--){
        idx = tmp.lastIndexOf(c);
        if(idx == -1) {
          break;
        tmp = tmp.substring(0,idx);
    ...
    
  7. trimToLength(m)
    String.prototype.trimToLength = function(m) {
      return (this.length > m) 
        ? jQuery.trim(this).substring(0, m).split(" ").slice(0, -1).join(" ") + "..."
        : this;
    };
    
  8. trimToLength(m)
    String.prototype.trimToLength = function(m) {
      return (this.length > m) 
        ? jQuery.trim(this).substring(0, m).split(" ").slice(0, -1).join(" ") + "..."
        : this;
    };
    
  9. trimToLength(m)
    String.prototype.trimToLength = function(m) {
      return (this.length > m) ? jQuery.trim(this).substring(0, m).split(' ').slice(0, -1).join(' ') : this.replace('"', '');
    };