Skip to main content

like_match

Function like_match 

Source
pub fn like_match(text: &str, pattern: &str, case_insensitive: bool) -> bool
Expand description

SQL LIKE matcher.

Wildcards: % matches any (possibly empty) char sequence; _ matches exactly one char. \ escapes the next char (so \% matches a literal percent). When case_insensitive is true, ASCII letters fold; non-ASCII characters compare by code-point (we don’t pull in Unicode case folding for v1).

Iterative two-pointer with backtracking — no recursion, so adversarial patterns like %a%a%a%a%a%b against aaaa…aa can’t blow the stack. Worst case is O(|text| · |pattern|).