MCPcopy Create free account
hub / github.com/apache/datafusion / compile_regex

Function compile_regex

datafusion/functions/src/regex/mod.rs:149–166  ·  view source on GitHub ↗
(regex: &str, flags: Option<&str>)

Source from the content-addressed store, hash-verified

147}
148
149pub fn compile_regex(regex: &str, flags: Option<&str>) -> Result<Regex, ArrowError> {
150 let pattern = match flags {
151 None | Some("") => regex.to_string(),
152 Some(flags) => {
153 if flags.contains("g") {
154 return Err(ArrowError::ComputeError(
155 "regexp_count()/regexp_instr() does not support the global flag"
156 .to_string(),
157 ));
158 }
159 format!("(?{flags}){regex}")
160 }
161 };
162
163 Regex::new(&pattern).map_err(|_| {
164 ArrowError::ComputeError(format!("Regular expression did not compile: {pattern}"))
165 })
166}

Callers 2

regexp_count_innerFunction · 0.85
compile_and_cache_regexFunction · 0.85

Calls 3

newFunction · 0.85
to_stringMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…