Zsh Mailing List Archive
Messages sorted by:
please consider using PCRE_DOLLAR_ENDONLY (and PCRE_DOTALL) for rematchpcre
- X-seq: zsh-workers 42044
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: please consider using PCRE_DOLLAR_ENDONLY (and PCRE_DOTALL) for rematchpcre
- Date: Wed, 22 Nov 2017 12:25:19 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mail-followup-to:mime-version :content-disposition:user-agent; bh=4AUbWdyZ2V1U/Jpp+H5iusZy5p/5o8CFOJt+3pJFkUk=; b=BKpGh1FhYpwSbr0H0YtP2GnUyXOV3v/bVZJmpyMv2/an/rMo3I0XKJ1/uhqMnLQK9f EnJJKiR5thwNwa2BwQx793v6waDDrJ5U2h7/dDsbuYzYocn11YcTudVSc7WZYERahBpU Tzbi2DM8/ZIzYB5SjSd8hesSXR3CFPasIO7Xukqxz03LTvrAEPFO0Xua1Cvne45DNIVN sLx4t+HRw7OlKGJG2/2uQEswh6Oneq9UwoOor5ZpsbMG0TNDNoGfGHbunFrKG2YD5NlX SC1iR6ZB6WYLBD01Hps2AJ5JxAtCYstTB27ZeSPWWBgmmMZLfoRUmxznE2+57NgYhOD2 D38Q==
- List-help: <mailto:firstname.lastname@example.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:email@example.com>
- List-unsubscribe: <mailto:firstname.lastname@example.org>
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
With setopt rematchpcre
[[ $a =~ a$ ]] currently matches on a=$'a\n'
[[ $a =~ ^$ ]] matches on a=$'\n'
While [[ $a =~ . ]] does *not* match on a=$'\n'
That can be quite surprising, and means the behaviour is
different from when using ERE (with norematchpcre)
It can be worked around ([[ $a =~ 'a\z' ]], [[ $a =~ '(?s).'
]]), but IMO at least PCRE_DOLLAR_ENDONLY (if not PCRE_DOTALL)
should be the default at least for [[ $string =~ ... ]] as
in shells, $string usually do not include the newline delimiter.
fish has the same issue with its "string" builtin.
ksh93 with [[ $var =~ (?P)pcre ]] does behave as if both
PCRE_DOLLAR_ENDONLY and PCRE_DOTALL were on.
Note that even with $PCRE_DOLLAR_ENDONLY, one can still do
line-based matching with (?m) or match before the trailing
newline character with \Z.
[[ $'a\nb\n' =~ '(?m)a$' ]] and [[ $'a\nb\n' =~ 'b\Z' ]] return
Messages sorted by: