Skip to main content

translate_pattern

Function translate_pattern 

Source
pub fn translate_pattern(pattern: &str) -> String
Expand description

Translates shell-style glob pattern to regex pattern.

This implements the same logic as Sphinx’s _translate_pattern function:

  • ** matches everything, including directory separators
    • matches everything except a directory separator
  • ? matches any single character except a directory separator
  • [seq] matches any character in seq
  • [!seq] matches any character not in seq (never a directory separator)

Based on Python’s fnmatch.translate but with modifications for path handling.