Use the aho-corasick algorithm to find matches
Description
This function determines if any of the patterns find a match.
Usage
<Expr>$str$contains_any(patterns, ..., ascii_case_insensitive = FALSE)
Arguments
patterns
|
Character vector or something can be coerced to strings Expr of a valid regex pattern, compatible with the regex crate. |
…
|
Ignored. |
ascii_case_insensitive
|
Enable ASCII-aware case insensitive matching. When this option is enabled, searching will be performed without respect to case for ASCII letters (a-z and A-Z) only. |
Value
Expr of Boolean data type
See Also
-
\
$str$contains()
Examples
library("polars")
df = pl$DataFrame(
lyrics = c(
"Everybody wants to rule the world",
"Tell me what you want, what you really really want",
"Can you feel the love tonight"
)
)
df$with_columns(
contains_any = pl$col("lyrics")$str$contains_any(c("you", "me"))
)
#> shape: (3, 2)
#> ┌─────────────────────────────────┬──────────────┐
#> │ lyrics ┆ contains_any │
#> │ --- ┆ --- │
#> │ str ┆ bool │
#> ╞═════════════════════════════════╪══════════════╡
#> │ Everybody wants to rule the wo… ┆ false │
#> │ Tell me what you want, what yo… ┆ true │
#> │ Can you feel the love tonight ┆ true │
#> └─────────────────────────────────┴──────────────┘