Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Regular expression expanding and matching
- X-seq: zsh-users 17434
- From: Vin Shelton <acs@xxxxxxxxxxxxxxxxxxxx>
- To: Mark van Dijk <lists+zsh@xxxxxxxxxxxxxx>
- Subject: Re: Regular expression expanding and matching
- Date: Sun, 25 Nov 2012 13:30:45 -0500
- Cc: "zsh-users@xxxxxxx" <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=WU+//DWV0/uLGLj/1L1Eqebs3tMAw+IfICiHntvAQy4=; b=hmN2E5/3WVtLX7TX3RAE8h2VU9IoWlkgKzTxekJfkh6YerTu67nZCxG1BOVi9Xmlwq 8771OnIlkwi2GCT52am2FTDuxFDjeVtsBea0N8dUE/EMGkFYRZDq6f7OYqTA8UQQytNF ytnCR3taoQPFyuV4eZC4jWr+CMAFFRhJ61SspdhP0mjB2UOGHGGCwu31OdI1hMyExMoF miUk5Wy2cmCWA7zqGiU/qaIUD8YLycacL+mW3gk4n3bRVTmozWYHAL6OnDwqH2S79+eM cpVg6NhX8awHSKpFVpFelT89oaMbr//GJs3QN3XKOY3H7/2W58iXdv2cOfaXTwnuwymg 6sKw==
- In-reply-to: <50B23D2D.9060603@internecto.net>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <50B23D2D.9060603@internecto.net>
- Sender: ethersoft@xxxxxxxxx
On Sun, Nov 25, 2012 at 10:45 AM, Mark van Dijk
<lists+zsh@xxxxxxxxxxxxxx> wrote:
> Apparently there is no expansion of ${todaysday} and ${yesterday}.
> This is not really surprising because in regular expressions many
> characters have a different meaning.
>So what's the proper way to achieve this type of expression matching?
Enclosing the expressions in double quotes seems to work for me:
if [[ $somestring -pcre-match "\d{4}${todaysday}" ]]; then
echo "somestring matches today"
elif [[ $somestring -pcre-match "\d{4}${yesterday}" ]]; then
echo "somestring matches yesterday"
fi
+./tt:8> [[ $somestring -pcre-match "\d{4}${todaysday}" ]]
+./tt:9> echo 'somestring matches today'
somestring matches today
Regards,
Vin
Messages sorted by:
Reverse Date,
Date,
Thread,
Author