Message from discussion
Reading hexadecimal numbers
Received: by 10.180.91.231 with SMTP id ch7mr3178963wib.1.1350352697584;
Mon, 15 Oct 2012 18:58:17 -0700 (PDT)
MIME-Version: 1.0
Path: q11ni134324947wiw.1!nntp.google.com!feeder1.cambriumusenet.nl!feeder3.cambriumusenet.nl!feed.tweaknews.nl!94.232.116.11.MISMATCH!feed.xsnews.nl!border-1.ams.xsnews.nl!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news.panservice.it!feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From: arn...@skeeve.com (Aharon Robbins)
Newsgroups: comp.lang.awk
Subject: Re: Reading hexadecimal numbers
Date: Wed, 10 Oct 2012 18:04:27 +0000 (UTC)
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <k54dbb$cjj$1@dont-email.me>
References: <201210011523092493@webuse.net> <20121009220128.634@kylheku.com> <k53tak$20b$1@dont-email.me> <20121010095732.587@kylheku.com>
Injection-Date: Wed, 10 Oct 2012 18:04:27 +0000 (UTC)
Injection-Info: mx04.eternal-september.org; posting-host="53d0dc8b7b7786a8769594ca2ee0c9b0";
logging-data="12915"; mail-complaints-to="ab...@eternal-september.org"; posting-account="U2FsdGVkX19/DADb6GDEge+yFTy475S6h33k3H2P2Bk="
Originator: arnold@chumley.(none) (Aharon Robbins)
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Cancel-Lock: sha1:Rj3FI54P9Qa+Z5BkVPC1V2GdvIQ=
Bytes: 2070
In article <20121010095732....@kylheku.com>,
Kaz Kylheku <k...@kylheku.com> wrote:
>One use for assignment might be to set up a configuration area in the program
>where it is customized.
>
>What if the regex is to occur in multiple places? If it's not in a variable,
>it has to be repeated.
This is why, since ~ 1988, awk has allowed the use of string variables
(and constants) where regexp constants are typically used. Thus
BEGIN { x = "foo{3,5}(bar)+" }
...
$0 ~ x { ... }
{ ... ; if (match(a, x)) ... }
It's not a 1-for-1 swap, and there are some caveats to be aware of
when doing this, documented in the gawk manual, but this kind of thing
is possible.
Just for the record, while I agree it would have been nice to have /regex/
as first class objects, it wasn't done, and it's too late now.
--
Aharon (Arnold) Robbins arnold AT skeeve DOT com
P.O. Box 354 Home Phone: +972 8 979-0381
Nof Ayalon Cell Phone: +972 50 729-7545
D.N. Shimshon 99785 ISRAEL