Skip to content

Commit

Permalink
Add an example for (?m)^ matching at end of text
Browse files Browse the repository at this point in the history
  • Loading branch information
robinst committed Oct 13, 2017
1 parent d5c8257 commit 7b4320d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ Notice that the `a+` matches either `a` or `A`, but the `b+` only matches
`b`.
Multi-line mode means `^` and `$` no longer match just at the beginning/end of
the input:
the input, but at the beginning/end of lines:
```
# use regex::Regex;
Expand All @@ -407,6 +407,15 @@ let m = re.find("line one\nline 2\n").unwrap();
assert_eq!(m.as_str(), "line 2");
```
Note that `^` matches after new lines, even at the end of input:
```
# use regex::Regex;
let re = Regex::new(r"(?m)^").unwrap();
let m = re.find_iter("test\n").last().unwrap();
assert_eq!((m.start(), m.end()), (5, 5));
```
Here is an example that uses an ASCII word boundary instead of a Unicode
word boundary:
Expand Down

0 comments on commit 7b4320d

Please sign in to comment.