4
[JavaScript] Remove Leading and Trailing Whitespaces
source link: https://siongui.github.io/2012/10/09/javascript-remove-leading-trailing-whitespace/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
[JavaScript] Remove Leading and Trailing Whitespaces
Updated: February 22, 2015This post is a brief summary of links in the references.
Remove (Trim) Leading Whitespace (similar to Python lstrip)
function lstrip(str) { return str.replace(/^\s+/g, ""); }
Remove (Trim) Trailing Whitespace (similar to Python rstrip)
function rstrip(str) { return str.replace(/\s+$/g, ""); }
Author: Siong-Ui Te ∈ Category: JavaScript
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK