[Vuejs]-How can I split a string based on two delimiters?

4👍

You can try with RegEx:

let dc = dataClub.split(/[\n;]/)
👤Mamun

1👍

One option is to use a regular expression between either ; or \n:

const doSplit = str => str.split(/;|\n/);

console.log(doSplit("- City\n - MU\n - Liverpool\n - Arsenal\n - Chelsea"));
console.log(doSplit("City;MU;Liverpool;Arsenal;Chelsea"));

Leave a comment