MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / regExpLeadsToEndlessLoop

Function regExpLeadsToEndlessLoop

src/test/datascience/wordHelper.ts:154–166  ·  view source on GitHub ↗
(regexp: RegExp)

Source from the content-addressed store, hash-verified

152}
153
154export function regExpLeadsToEndlessLoop(regexp: RegExp): boolean {
155 // Exit early if it's one of these special cases which are meant to match
156 // against an empty string
157 if (regexp.source === '^' || regexp.source === '^$' || regexp.source === '$' || regexp.source === '^\\s*$') {
158 return false;
159 }
160
161 // We check against an empty string. If the regular expression doesn't advance
162 // (e.g. ends in an endless loop) it will match an empty string.
163 const match = regexp.exec('');
164 // eslint-disable-next-line @typescript-eslint/no-explicit-any
165 return !!(match && <any>regexp.lastIndex === 0);
166}
167
168export const DefaultWordPattern =
169 /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g;

Callers 1

Calls 1

execMethod · 0.65

Tested by

no test coverage detected