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

Function globToRegex

src/bin/codegraph.ts:2192–2200  ·  view source on GitHub ↗

* Convert glob pattern to regex

(pattern: string)

Source from the content-addressed store, hash-verified

2190 * Convert glob pattern to regex
2191 */
2192function globToRegex(pattern: string): RegExp {
2193 const escaped = pattern
2194 .replace(/[.+^${}()|[\]\\]/g, '\\$&')
2195 .replace(/\*\*/g, '{{GLOBSTAR}}')
2196 .replace(/\*/g, '[^/]*')
2197 .replace(/\?/g, '[^/]')
2198 .replace(/\{\{GLOBSTAR\}\}/g, '.*');
2199 return new RegExp(escaped);
2200}
2201
2202/**
2203 * Print files as a tree

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected