escapeRegExp() function
str에 포함된 RegExp 특수 문자 ^, $, \, ., *, +, ?, (, ), [, ], {, }, |를 이스케이프하여, 결과를 new RegExp의 리터럴 패턴으로 사용할 수 있게 합니다.
Signature:
typescript
function escapeRegExp(str: string): string;Example
ts
escapeRegExp("[fxts](https://fxts.dev/)"); // "\\[fxts\\]\\(https://fxts\\.dev/\\)"
const re = new RegExp(escapeRegExp("$1.00"));
re.test("price: $1.00"); // true