Groups | Search | Server Info | Login | Register


Groups > comp.lang.awk > #134

Re: Regular expression in awk

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 <geoff@clare.See-My-Signature.invalid>
Subject Re: Regular expression in awk
References <4e09d4fd-8351-45f0-8f17-b6ac0d32e19a@l18g2000yql.googlegroups.com> <ini7kr$410$1@news.m-online.net> <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 <qjn078-7j2.ln1@leafnode-msgid.gclare.org.uk> (permalink)
Lines 27
Organization Zen Internet
NNTP-Posting-Host d54ab101.news.zen.co.uk
X-Trace DXC=HRbZh\?fF7H2[5<l_^TQjKYjZGX^207PK`<MJMoM3PFMT7@3fVMi2ZFU]U^0dkcTjNaL>KGR9O9IJZ[aEk6ckgmE
X-Complaints-To abuse@zen.co.uk
Xref x330-a1.tempe.blueboxinc.net comp.lang.awk:134

Show key headers only | View raw


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 <netnews@gclare.org.uk>

Back to comp.lang.awk | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Regular expression in awk gio001 <gcrippa@gmail.com> - 2011-04-06 07:40 -0700
  Re: Regular expression in awk pk <pk@pk.invalid> - 2011-04-06 16:01 +0100
  Re: Regular expression in awk Janis Papanagnou <janis_papanagnou@hotmail.com> - 2011-04-06 19:24 +0200
    Re: Regular expression in awk Manuel Collado <m.collado@domain.invalid> - 2011-04-06 21:07 +0200
    Re: Regular expression in awk gio001 <gcrippa@gmail.com> - 2011-04-06 12:25 -0700
      Re: Regular expression in awk Janis Papanagnou <janis_papanagnou@hotmail.com> - 2011-04-06 23:09 +0200
        Re: Regular expression in awk gio001 <gcrippa@gmail.com> - 2011-04-06 19:59 -0700
          Re: Regular expression in awk Loki Harfagr <l0k1@thedarkdesign.free.fr.INVALID> - 2011-04-07 07:32 +0000
            Re: Regular expression in awk gio001 <gcrippa@gmail.com> - 2011-04-07 05:06 -0700
              Re: Regular expression in awk Loki Harfagr <l0k1@thedarkdesign.free.fr.INVALID> - 2011-04-07 13:34 +0000
                Re: Regular expression in awk gio001 <gcrippa@gmail.com> - 2011-04-07 08:27 -0700
                Re: Regular expression in awk Loki Harfagr <l0k1@thedarkdesign.free.fr.INVALID> - 2011-04-07 18:32 +0000
      Re: Regular expression in awk Geoff Clare <geoff@clare.See-My-Signature.invalid> - 2011-04-07 13:34 +0100
        Re: Regular expression in awk arnold@skeeve.com (Aharon Robbins) - 2011-04-07 13:31 +0000
          Re: Regular expression in awk Geoff Clare <geoff@clare.See-My-Signature.invalid> - 2011-04-08 13:18 +0100

csiph-web