I\'d like to split a string only the at the first n occurrences of a delimiter. I know, I could add them together using a loop, but isn\'t there a more straight forward appr
Nothing a one simple regex can't do:
const string = 'Split this, but not this'; console.log(string.match(/^(\S+)\s*(\S+)?\s*([\s\S]+)?$/).slice(1));