From dc6edf9191fe751de236bf51b30981c937d1d784 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 17 Oct 2023 15:23:58 +0530 Subject: [PATCH] Improve the docs for how to match multi-line hints See #6692 --- kittens/hints/main.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/kittens/hints/main.py b/kittens/hints/main.py index cfb678fa3..87150b857 100644 --- a/kittens/hints/main.py +++ b/kittens/hints/main.py @@ -115,14 +115,16 @@ controls where to display the selected error message, other options are ignored. --regex default={default_regex} The regular expression to use when option :option:`--type` is set to -:code:`regex`, in python syntax. If you specify a numbered group in the regular +:code:`regex`, in Perl 5 syntax. If you specify a numbered group in the regular expression, only the group will be matched. This allow you to match text ignoring a prefix/suffix, as needed. The default expression matches lines. To -match text over multiple lines, you should prefix the regular expression with -:code:`(?ms)`, which turns on MULTILINE and DOTALL modes for the regex engine. -If you specify named groups and a :option:`--program`, then the program will be -passed arguments corresponding to each named group of the form -:code:`key=value`. +match text over multiple lines, things get a little tricky, as line endings +are a sequence of zero or more null bytes followed by either a carriage return +or a newline character. To have a pattern match over line endings you will need to +match the character set ``[\0\r\n]``. The newlines and null bytes are automatically +stripped from the returned text. If you specify named groups and a +:option:`--program`, then the program will be passed arguments corresponding +to each named group of the form :code:`key=value`. --linenum-action