Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Regular expression expanding and matching



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