/** * Escape all regex metacharacters in a string so it can be used literally * inside a RegExp constructor. Used internally by the interpolation * engine to compile placeholder patterns from caller-supplied delimiters, * and exported as a standalone helper for consumers building their own * delimiter-aware patterns. */ export function escapeRegex(str: string): string { return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); }