Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Handling of escaped plus sign ("+") in regular expressions
- X-seq: zsh-workers 45866
- From: Eric Cook <llua@xxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Handling of escaped plus sign ("+") in regular expressions
- Date: Wed, 20 May 2020 15:51:30 -0400
- In-reply-to: <CAALaScm2RSFT9=FnWWEVXkkxV_KuSO9-z9Jv1NMeuex_9eF9TQ@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAALaScm2RSFT9=FnWWEVXkkxV_KuSO9-z9Jv1NMeuex_9eF9TQ@mail.gmail.com>
On 5/20/20 3:18 PM, Marco Trevisan wrote:
Hi,
I've been using zsh to run some local scripts I was normally running with
bash and while most of them work as expected, there's a case that weirdly
failed to me (using zsh 5.8):
[[ +123 =~ ^+[0-9]+$ ]]
zsh: failed to compile regex: Invalid preceding regular expression
[[ +123 =~ ^\+[0-9]+$ ]]
zsh: failed to compile regex: Invalid preceding regular expression
The same behavior seems to apply both using RE_MATCH_PCRE and not.
As said, both matches correctly using bash.
Using something like
[[ +123 =~ ^[+][0-9]+$ ]]
Works as expected instead.
bash's [[ =~ uses regex from the libc it was compiled against last time i checked.
and with libc's for the systems i have available, that won't work. it doesn't spit
out an error message like zsh does, but it correctly does not match the invalid regex.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author