Trim a string by replacing string with regex - Node.js String

Node.js examples for String:Trim

Description

Trim a string by replacing string with regex

Demo Code



function _trim(str) {
    return str.replace(/^\s+/, '').replace(/\s+$/, '');
}

Related Tutorials