Function regexp_is_match
pub fn regexp_is_match<'a, S1, S2, S3>(
array: &'a S1,
regex_array: &'a S2,
flags_array: Option<&'a S3>,
) -> Result<BooleanArray, ArrowError>
Expand description
Return BooleanArray indicating which strings in an array match an array of regular expressions.
This is equivalent to the SQL array ~ regex_array
, supporting
StringArray
/ LargeStringArray
/ StringViewArray
.
If regex_array
element has an empty value, the corresponding result value is always true.
flags_array
are optional StringArray
/ LargeStringArray
/ StringViewArray
flag,
which allow special search modes, such as case-insensitive and multi-line mode.
See the documentation here
for more information.
§See Also
regexp_is_match_scalar
for matching a single regular expression against an array of stringsregexp_match
for extracting groups from a string array based on a regular expression
§Example
// First array is the array of strings to match
let array = StringArray::from(vec!["Foo", "Bar", "FooBar", "Baz"]);
// Second array is the array of regular expressions to match against
let regex_array = StringArray::from(vec!["^Foo", "^Foo", "Bar$", "Baz"]);
// Third array is the array of flags to use for each regular expression, if desired
// (the type must be provided to satisfy type inference for the third parameter)
let flags_array: Option<&StringArray> = None;
// The result is a BooleanArray indicating when each string in `array`
// matches the corresponding regular expression in `regex_array`
let result = regexp_is_match(&array, ®ex_array, flags_array).unwrap();
assert_eq!(result, BooleanArray::from(vec![true, false, true, true]));