arrow_string::predicate

Function regex_like

Source
fn regex_like(
    pattern: &str,
    case_insensitive: bool,
) -> Result<Regex, ArrowError>
Expand description

Transforms a like pattern to a regex compatible pattern. To achieve that, it does:

  1. Replace LIKE multi-character wildcards % => .* (unless they’re at the start or end of the pattern, where the regex is just truncated - e.g. %foo% => foo rather than ^.*foo.*$)
  2. Replace LIKE single-character wildcards _ => .
  3. Escape regex meta characters to match them and not be evaluated as regex special chars. e.g. . => \\.
  4. Replace escaped LIKE wildcards removing the escape characters to be able to match it as a regex. e.g. \\% => %