From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14651 invoked by alias); 25 Nov 2012 19:30:45 -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: 17438 Received: (qmail 11144 invoked from network); 25 Nov 2012 19:30:43 -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,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <121125113025.ZM15903@torch.brasslantern.com> Date: Sun, 25 Nov 2012 11:30:25 -0800 In-reply-to: <50B23D2D.9060603@internecto.net> Comments: In reply to Mark van Dijk "Regular expression expanding and matching" (Nov 25, 4:45pm) References: <50B23D2D.9060603@internecto.net> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Mark van Dijk , "zsh-users@zsh.org " Subject: Re: Regular expression expanding and matching MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Nov 25, 4:45pm, Mark van Dijk wrote: } } 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 } } Apparently there is no expansion of ${todaysday} and ${yesterday}. No, that's not what's happening here. What's happening is that the backslash is being removed by the shell command line parser before the regular expression is passed to the PCRE parser. Try 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 } +./zshtest:9> [[ $somestring -pcre-match \d{4}${todaysday} ]] } +./zshtest:11> [[ $somestring -pcre-match \d{4}${yesterday} ]] Hmm, there's something slighly off about that XTRACE output. Change the condition to -ef and you can see the real expansion: +./zshtest:9> [[ 121125 -ef 'd{4}25' ]] +./zshtest:11> [[ 121125 -ef 'd{4}24' ]] I'm not sure where the trace output is generated in the case of an infix condition operator that comes from a module, but I think there is a bug.