Initial Commit
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* 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, "\\$&");
|
||||
}
|
||||
Reference in New Issue
Block a user