From: Bart Schaefer <schaefer@brasslantern.com>
To: chris0e3@gmail.com
Cc: zsh-workers@zsh.org
Subject: Re: [BUG] `$match` is haunting my regex’s trailing, optional, capture
Date: Fri, 8 Dec 2023 22:23:10 -0800 [thread overview]
Message-ID: <CAH+w=7b8tF16GhZvpcF8urVV-tAAY6DHFRwp=7QNUfA27QxJhA@mail.gmail.com> (raw)
In-Reply-To: <A231AE39-13BE-487E-AE31-AF35F2891A8C@gmail.com>
On Fri, Dec 8, 2023 at 9:14 PM <chris0e3@gmail.com> wrote:
>
> setopt rematch_pcre
> [[ 'REQUIRE. OPT' =~ 'REQUIRE.(\s*OPT)?' ]] && printf '\tA. ‹%s›\n' $match
> [[ 'REQUIRE.' =~ 'REQUIRE.(\s*OPT)?' ]] && printf '\tB. ‹%s›\n' $match
Aside, you should use e.g. "$match[@]" there (including the quotes) or
you'll be surprised when there is more than one back reference.
> It looks like: if there is a match, but no captures are matched then `$match` is not cleared.
The output of your latter example is certainly not consistent with e.g.
setopt extendedglob
[[ 'REQUIRE.' = (#b)REQUIRE.(*OPT)(#c0,1) ]] && printf '\tB. ‹%s›\n' $match
And I can reproduce your example with the most recent git checkout, as
well. Oliver recently updated to pcre2, so if a patch appears, you
may be on your own to backport it.
next prev parent reply other threads:[~2023-12-09 6:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-09 5:14 chris0e3
2023-12-09 6:23 ` Bart Schaefer [this message]
2023-12-09 20:54 ` [PATCH?] " Bart Schaefer
2023-12-11 23:49 ` Oliver Kiddle
2023-12-12 1:38 ` Bart Schaefer
2024-01-25 22:14 ` Oliver Kiddle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAH+w=7b8tF16GhZvpcF8urVV-tAAY6DHFRwp=7QNUfA27QxJhA@mail.gmail.com' \
--to=schaefer@brasslantern.com \
--cc=chris0e3@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).