const regex = /(?:(?<=\{)|(?<=andmark)\s+)(['"])((?>[^'"]+)\1?)\1(?=\s+andmark|\})/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?:(?<=\\{)|(?<=andmark)\\s+)([\'"])((?>[^\'"]+)\\1?)\\1(?=\\s+andmark|\\})', 'g')
const str = `{'Born': {'(1991-09-05) September 5, 1991 (age\\xa025)\\nSebastian, Florida, U.S.'}, 'Weight': {'185 lbs'}, 'Favorite maneuvers': {'Airs and “barrels'}, 'Height': {'5\\'9"'...Lost, Erik Arakawa'}, 'there is table': {'true'}, 'Website': {'http://islandtocity.com/' andmark 'hello'}, 'exceptional_header_count': {'0'}}
`;
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) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions