Split text on more than one separator.

Splitting With Patterns

split_pattern.js
const text = "red blue green";
const parts = text.split(/[-; ]+/);
const count = parts.length;
const first = parts[0];
const last = parts[parts.length - 1];

console.log("count=" + count);
console.log("first=" + first);
console.log("last=" + last);
split-pattern `split` can use a regular expression when a string may contain different separators. A character class such as `[-; ]` lists the allowed separators.