I would like to get the text between double quotes using JavaScript. I found online something like title.match(/\".*?\"/);
but the thing is that sometimes I hav
In a single regex:
var m = s.match(/(?:"[^"]*"|^[^"]*$)/)[0].replace(/"/g, "");
TEST:
s = 'Neque "porro quisquam est" qui dolorem ipsum';
m = s.match(/(?:"[^"]*"|^[^"]*$)/)[0].replace(/"/g, "");
//=> porro quisquam est
s = 'Neque porro quisquam est qui dolorem ipsum';
m = s.match(/(?:"[^"]*"|^[^"]*$)/)[0].replace(/"/g, "");
//=> Neque porro quisquam est qui dolorem ipsum