MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / globToRegex

Function globToRegex

src/bin/codegraph.ts:2199–2207  ·  view source on GitHub ↗

* Convert glob pattern to regex

(pattern: string)

Source from the content-addressed store, hash-verified

2197 * Convert glob pattern to regex
2198 */
2199function globToRegex(pattern: string): RegExp {
2200 const escaped = pattern
2201 .replace(/[.+^${}()|[\]\\]/g, '\\$&')
2202 .replace(/\*\*/g, '{{GLOBSTAR}}')
2203 .replace(/\*/g, '[^/]*')
2204 .replace(/\?/g, '[^/]')
2205 .replace(/\{\{GLOBSTAR\}\}/g, '.*');
2206 return new RegExp(escaped);
2207}
2208
2209/**
2210 * Print files as a tree

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected