bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] Numerical repeat is broken.


From: Andrew J. Schorr
Subject: Re: [bug-gawk] Numerical repeat is broken.
Date: Fri, 17 Feb 2012 12:11:50 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

On Thu, Feb 16, 2012 at 03:23:01PM -0500, Pierre Chartier wrote:

BEGIN {
  printf "Matching v01.02.002\n"
  if("v01.02.002" ~ /v[0-9]{2}\.[0-9]{2}\.[0-9]{3}/) {printf "1 matches\n"}
  if("v01.02.002" ~ /v[0-9]*\.[0-9]*\.[0-9]*/) {printf "2 matches\n"}
  if("v01.02.002" ~ /v[0-9][0-9]\.[0-9]*\.[0-9]*/) {printf "3 matches\n"}
  if("v01.02.002" ~ /v[0-9]{2}\.[0-9]*\.[0-9]*/) {printf "4 matches\n"}
  if("v01.02.002" ~ /v[0-9]{2}\.[0-9]{2}\.[0-9]*/) {printf "5 matches\n"}
}

For this to work with gawk, you will need the --re-interval argument:

--re-interval
     Allow interval expressions in regexps, even if `--traditional' has
     been provided.  (`--posix' automatically enables interval
     expressions, so `--re-interval' is redundant when `--posix' is is
     used.)

Regards,
Andy



reply via email to

[Prev in Thread] Current Thread [Next in Thread]