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

Function globToRegex

src/bin/codegraph.ts:2064–2072  ·  view source on GitHub ↗

* Convert glob pattern to regex

(pattern: string)

Source from the content-addressed store, hash-verified

2062 * Convert glob pattern to regex
2063 */
2064function globToRegex(pattern: string): RegExp {
2065 const escaped = pattern
2066 .replace(/[.+^${}()|[\]\\]/g, '\\$&')
2067 .replace(/\*\*/g, '{{GLOBSTAR}}')
2068 .replace(/\*/g, '[^/]*')
2069 .replace(/\?/g, '[^/]')
2070 .replace(/\{\{GLOBSTAR\}\}/g, '.*');
2071 return new RegExp(escaped);
2072}
2073
2074/**
2075 * Print files as a tree

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected