这是我想出的:// Finds starting and ending positions of quoted text// in double or single quotes with escape char support like \" \'var str = "this is a \"quoted\" string as you can 'read'";var patt = /'((?:\\.|[^'])*)'|"((?:\\.|[^"])*)"/igm;while (match = patt.exec(str)) { console.log(match.index + ' ' + patt.lastIndex);}