From 21f46181d9c343160eb9b01ca6038217b23f1539 Mon Sep 17 00:00:00 2001 From: David Adam Date: Fri, 8 Jan 2021 21:16:07 +0800 Subject: [PATCH] string match: reword the named capture group documentation --- CHANGELOG.rst | 2 +- doc_src/cmds/string-match.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e5822b1d8..a62a8cd51 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -37,7 +37,7 @@ Notable improvements and fixes or non-matching wildcards, as these could be defined differently at runtime (especially for functions). This makes it usable as a static syntax checker (:issue:`977`). - ``type`` is now a builtin and therefore much faster (:issue:`7342`). -- ``string match --regex`` now imports named PCRE2 capture groups as fish variables (:issue:`7459`). To support this functionality, ``string`` is now a reserved word and can no longer be wrapped in a function. +- ``string match --regex`` now integrates named PCRE2 capture groups with fish variables, allowing variables to be set directly from ``string match`` (:issue:`7459`). To support this functionality, ``string`` is now a reserved word and can no longer be wrapped in a function. - Globs and other expansions are limited to 512k results (:issue:`7226`). Because operating systems limit arguments to ARG_MAX, larger values are unlikely to work anyway, and this helps to avoid hangs. - fish will now always attempt to become process group leader in interactive mode (:issue:`7060`). This helps avoid hangs in certain circumstances, and allows tmux's current directory introspection to work (:issue:`5699`). diff --git a/doc_src/cmds/string-match.rst b/doc_src/cmds/string-match.rst index b9a865123..1f05f4a6a 100644 --- a/doc_src/cmds/string-match.rst +++ b/doc_src/cmds/string-match.rst @@ -27,7 +27,7 @@ If ``--index`` or ``-n`` is given, each match is reported as a 1-based start pos If ``--regex`` or ``-r`` is given, PATTERN is interpreted as a Perl-compatible regular expression, which does not have to match the entire STRING. For a regular expression containing capturing groups, multiple items will be reported for each match, one for the entire match and one for each capturing group. With this, only the matching part of the STRING will be reported, unless ``--entire`` is given. -When matching via regular expressions, ``string match`` automatically imports all named capturing groups (``(?expression)``) as fish variables of the same name. It will create a variable in the default scope for each named capturing group, and set it to the value of the capturing group in the first matched argument. If a named capture group matched an empty string, the variable will be set to the empty string (like ``set var ""``). If it did not match, the variable will be set to nothing (like ``set var``). When ``--regex`` is used with ``--all``, this behavior changes. Each named variable will contain a list of matches, with the first match contained in the first element, the second match in the second, and so on. If the group was empty or did not match, the corresponding element will be an empty string. +When matching via regular expressions, ``string match`` automatically sets variables for all named capturing groups (``(?expression)``). It will create a variable with the name of the group, in the default scope, for each named capturing group, and set it to the value of the capturing group in the first matched argument. If a named capture group matched an empty string, the variable will be set to the empty string (like ``set var ""``). If it did not match, the variable will be set to nothing (like ``set var``). When ``--regex`` is used with ``--all``, this behavior changes. Each named variable will contain a list of matches, with the first match contained in the first element, the second match in the second, and so on. If the group was empty or did not match, the corresponding element will be an empty string. If ``--invert`` or ``-v`` is used the selected lines will be only those which do not match the given glob pattern or regular expression.