MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / write_regex_to

Method write_regex_to

src/expr/src/scalar/like_pattern.rs:223–246  ·  view source on GitHub ↗

Converts a Subpattern to an equivalent regular expression and writes it to a given string.

(&self, r: &mut String)

Source from the content-addressed store, hash-verified

221impl Subpattern {
222 /// Converts a Subpattern to an equivalent regular expression and writes it to a given string.
223 fn write_regex_to(&self, r: &mut String) {
224 match self.consume {
225 0 => {
226 if self.many {
227 r.push_str(".*");
228 }
229 }
230 1 => {
231 r.push('.');
232 if self.many {
233 r.push('+');
234 }
235 }
236 n => {
237 r.push_str(".{");
238 write!(r, "{}", n);
239 if self.many {
240 r.push(',');
241 }
242 r.push('}');
243 }
244 }
245 regex_syntax::escape_into(&self.suffix, r);
246 }
247}
248
249fn is_match_subpatterns(subpatterns: &[Subpattern], mut text: &str) -> bool {

Callers 1

build_regexFunction · 0.80

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected