Download next.js/packages/next/src/shared/lib/escape-regexp.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 427 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/shared/lib/escape-regexp.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/packages/next/src/shared/lib/escape-regexp.ts
-
curl -L -o escape-regexp.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/shared/lib/escape-regexp.ts
427 Bytes
| // regexp is based on https://github.com/sindresorhus/escape-string-regexp | |
| const reHasRegExp = /[|\\{}()[\]^$+*?.-]/ | |
| const reReplaceRegExp = /[|\\{}()[\]^$+*?.-]/g | |
| export function escapeStringRegexp(str: string) { | |
| // see also: https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/escapeRegExp.js#L23 | |
| if (reHasRegExp.test(str)) { | |
| return str.replace(reReplaceRegExp, '\\$&') | |
| } | |
| return str | |
| } | |