Lines Matching defs:new
61 /// Creates a new match from the given haystack and byte offsets.
63 fn new(haystack: &'t str, start: usize, end: usize) -> Match<'t> {
97 /// The only methods that allocate new strings are the string replacement
107 /// let re = Regex::new("[0-9]{3}-[0-9]{3}-[0-9]{4}").unwrap();
126 /// let re = Regex::new(r"\d+").unwrap();
164 Regex::new(s)
174 pub fn new(re: &str) -> Result<Regex, Error> {
175 RegexBuilder::new(re).build()
194 /// assert!(Regex::new(r"\b\w{13}\b").unwrap().is_match(text));
217 /// let mat = Regex::new(r"\b\w{13}\b").unwrap().find(text).unwrap();
239 /// for mat in Regex::new(r"\b\w{13}\b").unwrap().find_iter(text) {
266 /// let re = Regex::new(r"'([^']+)'\s+\((\d{4})\)").unwrap();
288 /// let re = Regex::new(r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)")
332 /// let re = Regex::new(r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)")
365 /// let re = Regex::new(r"[ \t]+").unwrap();
389 /// let re = Regex::new(r"\W+").unwrap();
436 /// let re = Regex::new("[^01]+").unwrap();
449 /// let re = Regex::new(r"([^,\s]+),\s+(\S+)").unwrap();
465 /// let re = Regex::new(r"(?P<last>[^,\s]+),\s+(?P<first>\S+)").unwrap();
482 /// let re = Regex::new(r"(?P<first>\w+)\s+(?P<second>\w+)").unwrap();
501 /// let re = Regex::new(r"(?P<last>[^,\s]+),\s+(\S+)").unwrap();
554 let mut new = String::with_capacity(text.len());
557 new.push_str(&text[last_match..m.start()]);
558 new.push_str(&rep);
564 new.push_str(&text[last_match..]);
565 return Cow::Owned(new);
574 let mut new = String::with_capacity(text.len());
579 new.push_str(&text[last_match..m.start()]);
580 rep.replace_append(&cap, &mut new);
586 new.push_str(&text[last_match..]);
587 Cow::Owned(new)
610 /// let pos = Regex::new(r"a+").unwrap().shortest_match(text);
656 .map(|(s, e)| Match::new(text, s, e))
692 .map(|(s, e)| Match::new(text, s, e))
940 /// let re = Regex::new(r"[a-z]+(?:([0-9]+)|([A-Z]+))").unwrap();
949 self.locs.pos(i).map(|(s, e)| Match::new(self.text, s, e))
1093 .map(|cap| cap.map(|(s, e)| Match::new(self.caps.text, s, e)))
1150 self.0.next().map(|(s, e)| Match::new(text, s, e))