From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29976 invoked by alias); 24 Feb 2011 11:21:21 -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: 15828 Received: (qmail 11672 invoked from network); 24 Feb 2011 11:21:19 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at spodhuis.org does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=spodhuis.org; s=d200912; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date; bh=utU0FpDgJLZx+dJ7dAX+NuJ6EdRYQ8scxBHDO08BhuQ=; b=S+F2gujBXPbGdynlVgwURekfw4g0I+7dailnboTIz0ttzwg15F55EqXj1HkGYVRCS4sKHYHjXdmTe3zpBVd3Oj0e2GCxKK7IUJRANF8VTMEMsP/RPa/wmzAUbgy779BqExWg5nS/X//3APwTEY5ZzXFs9LxqaQTpGe5qFT1CRZQ=; Date: Thu, 24 Feb 2011 06:21:14 -0500 From: Phil Pennock To: zsh-users@zsh.org Subject: Re: Regular expressions in zsh Message-ID: <20110224112114.GA14026@redoubt.spodhuis.org> Mail-Followup-To: zsh-users@zsh.org References: <20110219033809.GA72507@quark.hightek.org> <20110219054807.GA57597@redoubt.spodhuis.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On 2011-02-23 at 16:41 +0000, zzapper wrote: > Have you any illustrative examples of using REMATCH_PCRE? I keep a shell variable $ipv6_regex defined, with a PCRE regexp that matches IPv6 addresses. Lots of non-capturing sub-expressions. You can grab emit_ipv6_regexp from: http://people.spodhuis.org/phil.pennock/software/ Then it's just: [[ $foo =~ ^$ipv6_regex\$ ]] && echo IPv6 The other times it matters is when I'm using zero-width assertions, which are Rather Nice in those situation where you need them. As a rather contrived example, this will print out the name and value of all shell variables with "NAME" in their name, except for ZSH_NAME: for param in ${(k)parameters}; do [[ $param =~ '(?