From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2447 invoked by alias); 25 Nov 2012 15:55:24 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17433 Received: (qmail 5390 invoked from network); 25 Nov 2012 15:55:09 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at internecto.net designates 176.9.245.29 as permitted sender) X-Virus-Scanned: Debian amavisd-new at mail.internecto.net Message-ID: <50B23D2D.9060603@internecto.net> Date: Sun, 25 Nov 2012 16:45:49 +0100 From: Mark van Dijk User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: "zsh-users@zsh.org" Subject: Regular expression expanding and matching Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hello, I was trying to match a string with a regular expression as follows: --- #!/usr/local/bin/zsh zmodload zsh/pcre somestring="121125" todaysday="25" yesterday="24" set -xv 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 set +xv --- Relevant output: --- +./zshtest:9> [[ $somestring -pcre-match \d{4}${todaysday} ]] +./zshtest:11> [[ $somestring -pcre-match \d{4}${yesterday} ]] --- 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? Thank you, Mark