Вы можете легко split()
строку запятой ,
захватить первую часть и replace()
одинарные кавычки, чтобы выполнить свою работу, но если вам нужно регулярное выражение, то это может быть решением.
const regex = /"'?(.*?)'?(?:,|")/ig;
const str = `"'Helvetica Neue', Helvetica, sans-serif"
"Arial, 'Helvetica Neue', Helvetica, sans-serif"
"Arial"`;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
if (groupIndex == 1)
console.log(`${match}`);
});
}