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

Function globToRegex

src/bin/codegraph.ts:2143–2151  ·  view source on GitHub ↗

* Convert glob pattern to regex

(pattern: string)

Source from the content-addressed store, hash-verified

2141 * Convert glob pattern to regex
2142 */
2143function globToRegex(pattern: string): RegExp {
2144 const escaped = pattern
2145 .replace(/[.+^${}()|[\]\\]/g, '\\$&')
2146 .replace(/\*\*/g, '{{GLOBSTAR}}')
2147 .replace(/\*/g, '[^/]*')
2148 .replace(/\?/g, '[^/]')
2149 .replace(/\{\{GLOBSTAR\}\}/g, '.*');
2150 return new RegExp(escaped);
2151}
2152
2153/**
2154 * Print files as a tree

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected