(str: string, except?: string)
| 44 | export const isRegexSpecialChar = (chr: string) => regexChars.includes(chr); |
| 45 | |
| 46 | export 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 | |
| 57 | export class PositionToOffset { |
| 58 | private readonly lines: number[] = []; |
no test coverage detected