MCPcopy Create free account
hub / github.com/bernaferrari/FigmaToCode / escapeRegExp

Function escapeRegExp

packages/backend/src/common/numToAutoFixed.ts:83–85  ·  view source on GitHub ↗
(string: string)

Source from the content-addressed store, hash-verified

81};
82
83function escapeRegExp(string: string) {
84 return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
85}
86
87export const replaceAllUtil = (str: string, find: string, replace: string) =>
88 str.replace(new RegExp(escapeRegExp(find), "g"), replace);

Callers 1

replaceAllUtilFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected