const MEMORY_ID_RE = /(? = []; for (const expression of DELIMITED_LIST_RES) { for (const match of text.matchAll(expression)) { const contents = match[1]; if (contents !== undefined && MEMORY_ID_LIST_RE.test(contents)) { const start = (match.index ?? 0) + 1; delimitedRanges.push([start, start + contents.length]); } } } const ids: string[] = []; const seen = new Set(); for (const match of text.matchAll(MEMORY_ID_RE)) { const id = match[1]; const index = match.index ?? -1; const explicitlyDelimited = delimitedRanges.some(([start, end]) => index >= start && index < end); const hashLike = /[0-9]/.test(id) && /[a-f]/.test(id); if ((!explicitlyDelimited && !hashLike) || seen.has(id)) continue; seen.add(id); ids.push(id); } return ids; }