@@ -18,8 +18,10 @@ use parse;
18
18
use vm;
19
19
use vm:: { CaptureLocs , MatchKind , Exists , Location , Submatches } ;
20
20
21
- /// Escapes all regular expression meta characters in `text` so that it may be
22
- /// safely used in a regular expression as a literal string.
21
+ /// Escapes all regular expression meta characters in `text`.
22
+ ///
23
+ /// The string returned may be safely used as a literal in a regular
24
+ /// expression.
23
25
pub fn quote ( text : & str ) -> String {
24
26
let mut quoted = String :: with_capacity ( text. len ( ) ) ;
25
27
for c in text. chars ( ) {
@@ -45,17 +47,18 @@ pub fn is_match(regex: &str, text: &str) -> Result<bool, parse::Error> {
45
47
Regex :: new ( regex) . map ( |r| r. is_match ( text) )
46
48
}
47
49
48
- /// Regex is a compiled regular expression, represented as either a sequence
49
- /// of bytecode instructions (dynamic) or as a specialized Rust function
50
- /// (native). It can be used to search, split
50
+ /// A compiled regular expression
51
+ ///
52
+ /// It is represented as either a sequence of bytecode instructions (dynamic)
53
+ /// or as a specialized Rust function (native). It can be used to search, split
51
54
/// or replace text. All searching is done with an implicit `.*?` at the
52
55
/// beginning and end of an expression. To force an expression to match the
53
56
/// whole string (or a prefix or a suffix), you must use an anchor like `^` or
54
57
/// `$` (or `\A` and `\z`).
55
58
///
56
59
/// While this crate will handle Unicode strings (whether in the regular
57
60
/// expression or in the search text), all positions returned are **byte
58
- /// indices**. Every byte index is guaranteed to be at a UTF8 codepoint
61
+ /// indices**. Every byte index is guaranteed to be at a Unicode code point
59
62
/// boundary.
60
63
///
61
64
/// The lifetimes `'r` and `'t` in this crate correspond to the lifetime of a
@@ -189,7 +192,7 @@ impl Regex {
189
192
///
190
193
/// # Example
191
194
///
192
- /// Find the start and end location of every word with exactly 13
195
+ /// Find the start and end location of the first word with exactly 13
193
196
/// characters:
194
197
///
195
198
/// ```rust
@@ -216,7 +219,7 @@ impl Regex {
216
219
///
217
220
/// # Example
218
221
///
219
- /// Find the start and end location of the first word with exactly 13
222
+ /// Find the start and end location of every word with exactly 13
220
223
/// characters:
221
224
///
222
225
/// ```rust
@@ -577,8 +580,8 @@ impl<'t> Replacer for &'t str {
577
580
}
578
581
}
579
582
580
- impl < ' a > Replacer for |& Captures |: ' a -> String {
581
- fn reg_replace<' r >( & ' r mut self , caps : & Captures ) -> MaybeOwned < ' r > {
583
+ impl < ' t > Replacer for |& Captures |: ' t -> String {
584
+ fn reg_replace<' a >( & ' a mut self , caps : & Captures ) -> MaybeOwned < ' a > {
582
585
Owned ( ( * self ) ( caps) )
583
586
}
584
587
}
@@ -823,8 +826,9 @@ impl<'t> Iterator<Option<(uint, uint)>> for SubCapturesPos<'t> {
823
826
}
824
827
825
828
/// An iterator that yields all non-overlapping capture groups matching a
826
- /// particular regular expression. The iterator stops when no more matches can
827
- /// be found.
829
+ /// particular regular expression.
830
+ ///
831
+ /// The iterator stops when no more matches can be found.
828
832
///
829
833
/// `'r` is the lifetime of the compiled expression and `'t` is the lifetime
830
834
/// of the matched string.
0 commit comments