Skip to main content

regexp_matches_newline

Function regexp_matches_newline 

pub fn regexp_matches_newline(regexp: &str, dotall: bool) -> bool
Expand description

Whether regexp, as written (a to_regexp() output), may match text containing a newline (U+000A), erring toward yes (see the module doc) — the newline_types predicate for a grammar with no grammar-wide flag but re.S. The lexer asks compiled_matches_newline of the pattern it compiles, which also carries re.X, re.M and re.I.

dotall reflects the grammar-wide re.S/DOTALL bit (g_regex_flags), which the scanner applies to every terminal at match time. Under DOTALL a bare ./ANY consumes a newline, so the classifier must see the same flag or it would false-negative a dot-only terminal (e.g. /.+/ under re.S matches across newlines but would be excluded from newline_types, silently drifting line/column). Per-terminal flags are already baked into regexp.