diff --git a/src/expr/src/vector_op/regexp.rs b/src/expr/src/vector_op/regexp.rs index 32103ee24e0c1..1d83a895e1b0c 100644 --- a/src/expr/src/vector_op/regexp.rs +++ b/src/expr/src/vector_op/regexp.rs @@ -33,15 +33,10 @@ impl RegexpContext { fn new(pattern: &str, flags: &str, replacement: &str) -> Result { let options = RegexpOptions::from_str(flags)?; - // FIXME: Any better solution? - let mut origin = String::with_capacity(pattern.len()); - - if options.case_insensitive { - origin.push_str("(?i:"); - origin.push_str(pattern); - origin.push(')'); + let origin = if options.case_insensitive { + format!("(?i:{})", pattern) } else { - origin = pattern.to_string(); + pattern.to_string() }; Ok(Self {