Javascript modifies String object to add whitespace removing function of sample code

  • 2020-03-30 00:39:28
  • OfStack


//#region removes whitespace
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, "");
}
//#endregion 


Related articles: