Function datafusion_physical_expr::regex_expressions::regexp_match
source · pub fn regexp_match<T: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef>
Expand description
Extract a specific group from a string column, using a regular expression.
The full list of supported features and syntax can be found at https://docs.rs/regex/latest/regex/#syntax
Supported flags can be found at https://docs.rs/regex/latest/regex/#grouping-and-flags
§Examples
let ctx = SessionContext::new();
let df = ctx.read_csv("tests/data/regex.csv", CsvReadOptions::new()).await?;
// use the regexp_match function to test col 'values',
// against patterns in col 'patterns' without flags
let df = df.with_column(
"a",
regexp_match(vec![col("values"), col("patterns")])
)?;
// use the regexp_match function to test col 'values',
// against patterns in col 'patterns' with flags
let df = df.with_column(
"b",
regexp_match(vec![col("values"), col("patterns"), col("flags")]),
)?;
// literals can be used as well with dataframe calls
let df = df.with_column(
"c",
regexp_match(vec![lit("foobarbequebaz"), lit("(bar)(beque)")]),
)?;
df.show().await?;