Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!feeder.erje.net!xlned.com!feeder1.xlned.com!zen.net.uk!hamilton.zen.co.uk!reader02.news.zen.co.uk.POSTED!not-for-mail Newsgroups: comp.lang.awk From: Geoff Clare Subject: Re: Regular expression in awk References: <4e09d4fd-8351-45f0-8f17-b6ac0d32e19a@l18g2000yql.googlegroups.com> <02482113-48f0-4690-b20c-98f906b1cd51@w7g2000yqe.googlegroups.com> User-Agent: XPN/1.2.6 (Street Spirit ; Linux) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Date: Thu, 7 Apr 2011 13:34:34 +0100 Message-ID: Lines: 27 Organization: Zen Internet NNTP-Posting-Host: d54ab101.news.zen.co.uk X-Trace: DXC=HRbZh\?fF7H2[5KGR9O9IJZ[aEk6ckgmE X-Complaints-To: abuse@zen.co.uk Xref: x330-a1.tempe.blueboxinc.net comp.lang.awk:134 gio001 wrote: > I perfectly understand what you are suggesting, I tried this form in > vain: > awk '/PV1\|\([^|]*\|\)\{16\}\|X/ {print $0}}' infile > outfile > yet the same exact costruct works in > grep 'PV1\|\([^|]*\|\)\{16\}\|X' infile > outfile Without the -E option grep uses "basic regular expressions" (BREs), whereas awk uses "extended regular expressions" (EREs). There are some characters that are special in EREs but not in BREs. Some of these can be made special in BREs by preceding them with a backslash, but in EREs doing that makes them not special. The ERE equivalent of the BRE you used with grep is: PV1|([^|]*|){16}|X if your version of grep treats \| as special, or: PV1\|([^|]*\|){16}\|X if your version of grep does not treat \| as special. -- Geoff Clare