MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / glob_to_regex

Function glob_to_regex

crates/opencode-grep/src/search.rs:285–297  ·  view source on GitHub ↗
(pattern: &str)

Source from the content-addressed store, hash-verified

283 }
284
285 fn glob_to_regex(pattern: &str) -> regex::Regex {
286 let mut regex_str = String::from("^.*");
287 for c in pattern.chars() {
288 match c {
289 '*' => regex_str.push_str("[^/]*"),
290 '?' => regex_str.push_str("[^/]"),
291 '.' => regex_str.push_str("\\."),
292 _ => regex_str.push(c),
293 }
294 }
295 regex_str.push('$');
296 regex::Regex::new(&regex_str).unwrap_or_else(|_| regex::Regex::new(".*").unwrap())
297 }
298}
299
300#[cfg(test)]

Callers 1

glob_matchFunction · 0.85

Calls 1

newFunction · 0.85

Tested by

no test coverage detected