Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions googletest/src/matchers/contains_regex_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ use std::ops::Deref;
/// # should_pass_2().unwrap();
/// ```
///
/// # Regular Expression Syntax
///
/// The regular expression syntax matches that of the
/// [`regex` crate](https://docs.rs/regex). This is a linear-time regular
/// expression engine which does not support lookarounds or backreferences.
///
/// To enable multi-line matching (where `^` and `$` match line boundaries
/// instead of the start and end of the entire input), prefix the pattern with
/// `(?m)`.
///
/// For details on the supported syntax, see the
/// [regex crate documentation](https://docs.rs/regex/latest/regex/#syntax).
///
/// # Panics
///
/// Panics if the given `pattern` is not a syntactically valid regular
/// expression.
#[track_caller]
Expand Down
27 changes: 27 additions & 0 deletions googletest/src/matchers/matches_regex_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,33 @@ use std::ops::Deref;
/// # should_pass_2().unwrap();
/// ```
///
/// # Regular Expression Syntax
///
/// The regular expression syntax matches that of the
/// [`regex` crate](https://docs.rs/regex). This is a linear-time regular
/// expression engine which does not support lookarounds or backreferences.
///
/// For details on the supported syntax, see the
/// [regex crate documentation](https://docs.rs/regex/latest/regex/#syntax).
///
/// Note that `matches_regex` automatically wraps the pattern with `^` and `$`
/// to ensure it matches the entire string.
///
/// ## Multi-line matching
///
/// If you want to match a multi-line string where `.` matches newlines, use
/// the `(?s)` flag (e.g., `(?s)begin.*end`).
///
/// Avoid using the `(?m)` flag (multi-line mode) with `matches_regex`, as it
/// redefines `^` and `$` to match line boundaries. Because `matches_regex`
/// wraps your pattern in `^...$` and uses `is_match` internally, enabling
/// `(?m)` will cause the matcher to succeed if *any* single line matches the
/// pattern, rather than requiring the entire string to match. If you want to
/// match a pattern against individual lines of a multi-line string, use
/// [`contains_regex`][crate::matchers::contains_regex] with `(?m)` instead.
///
/// # Panics
///
/// Panics if the given `pattern` is not a syntactically valid regular
/// expression.
// N.B. This returns the concrete type rather than an impl Matcher so that it
Expand Down
Loading