(regex: &str, flags: Option<&str>)
| 147 | } |
| 148 | |
| 149 | pub 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 | } |
no test coverage detected
searching dependent graphs…