silverwolf-x/project / packages /next /src /shared /lib /escape-regexp.ts
silverwolf-x's picture
download
raw
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
}

Xet Storage Details

Size:
427 Bytes
·
Xet hash:
80f03aae926f18227cfba38bb8158eeb302d8181982cd4c403575b7e4b222734

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.