const regex = /(?n)(?i:{[a-f\d]{8}-?[a-f\d]{4}-?[a-f\d]{4}-?[a-f\d]{4}-?[a-f\d]{12}})|
(?i:\([a-f\d]{8}-?[a-f\d]{4}-?[a-f\d]{4}-?[a-f\d]{4}-?[a-f\d]{12}\))|
(?i:[a-f\d]{8}-?[a-f\d]{4}-?[a-f\d]{4}-?[a-f\d]{4}-?[a-f\d]{12})|
{0x[a-fA-F\d]{8},0x[a-fA-F\d]{4},0x[a-fA-F\d]{4},{0x[a-fA-F\d]{2},0x[a-fA-F\d]{2},0x[a-fA-F\d]{2},0x[a-fA-F\d]{2},0x[a-fA-F\d]{2},0x[a-fA-F\d]{2},0x[a-fA-F\d]{2},0x[a-fA-F\d]{2}}}
/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?n)(?i:{[a-f\\d]{8}-?[a-f\\d]{4}-?[a-f\\d]{4}-?[a-f\\d]{4}-?[a-f\\d]{12}})|
(?i:\\([a-f\\d]{8}-?[a-f\\d]{4}-?[a-f\\d]{4}-?[a-f\\d]{4}-?[a-f\\d]{12}\\))|
(?i:[a-f\\d]{8}-?[a-f\\d]{4}-?[a-f\\d]{4}-?[a-f\\d]{4}-?[a-f\\d]{12})|
{0x[a-fA-F\\d]{8},0x[a-fA-F\\d]{4},0x[a-fA-F\\d]{4},{0x[a-fA-F\\d]{2},0x[a-fA-F\\d]{2},0x[a-fA-F\\d]{2},0x[a-fA-F\\d]{2},0x[a-fA-F\\d]{2},0x[a-fA-F\\d]{2},0x[a-fA-F\\d]{2},0x[a-fA-F\\d]{2}}}
', 'g')
const str = `string str = @"
50de1696-8c63-4856-a204-7f4d93082da8
AB9B479D-3E48-49B7-A3B9-3BEC6ADEE344
d1ce1bec29434df09a03fc0605a2b481
DC9A9DA1D9D448DA8B9BDC401E20BA69
{8f60f165-38f9-42ad-95d2-22b746de1cba}
{DC9A9DA1-D9D4-48DA-8B9B-DC401E20BA69}
(f4e06eae-58d2-4daa-9f2d-917f622d23ea)
(DC9A9DA1-D9D4-48DA-8B9B-DC401E20BA69)
{0xB7D3E6C4,0x7FA6,0x4C48,{0xBA,0x0A,0x44,0x58,0x9D,0x14,0xE5,0x12}}
{0xf3ffac91,0xc8cd,0x434d,{0x9f,0x2d,0x78,0x93,0x9b,0xa4,0x82,0x1d}}
";`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 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