MCPcopy
hub / github.com/microsoft/vscode-js-debug / escapeRegexSpecialChars

Function escapeRegexSpecialChars

src/common/stringUtils.ts:46–55  ·  view source on GitHub ↗
(str: string, except?: string)

Source from the content-addressed store, hash-verified

44export const isRegexSpecialChar = (chr: string) => regexChars.includes(chr);
45
46export function escapeRegexSpecialChars(str: string, except?: string): string {
47 const useRegexChars = regexChars
48 .split('')
49 .filter(c => !except || except.indexOf(c) < 0)
50 .join('')
51 .replace(/[\\\]]/g, '\\$&');
52
53 const r = new RegExp(`[${useRegexChars}]`, 'g');
54 return str.replace(r, '\\$&');
55}
56
57export class PositionToOffset {
58 private readonly lines: number[] = [];

Callers 6

replacePathMethod · 0.90
constructorMethod · 0.90
createTargetFilterFunction · 0.90
_setByPathMethod · 0.90

Calls 2

replaceMethod · 0.65
filterMethod · 0.45

Tested by

no test coverage detected