Split string by comma and white space - Node.js String

Node.js examples for String:String Value

Description

Split string by comma and white space

Demo Code


String.prototype.splitByComma = function splitByComma() {
    return this.trim().split(/\s*,\s*/gi);
};
String.prototype.splitByWhiteSpace = function splitByWhiteSpace() {
    return this.trim().split(/\s+/gi);
};

Related Tutorials