Skip to main content

regex

Type created by the regex function.

def regex(
regex: str,
/,
*,
fancy: bool = False,
) -> BuckRegex

Compile a regular expression from a string.

Fanciness

Buck2 regexes support two backing implementations:

  • With fancy = False (the default), the regex crate is used. These regular expressions compile down to a DFA and match very quickly and efficiently (in linear time), but do not support look-around or backreferences.

  • With fancy = True, the fancy_regex crate is used, which does support look-around and backreferences, but is slower to match (exponential time in the worst case).


regex.match

def regex.match(
str: str,
/,
) -> bool

Determine if the regex matches any substring of the given string.