[Top][All Lists]

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

gawk regular expression extensions

From: Tony Ernst
Subject: gawk regular expression extensions
Date: Thu, 20 Jan 2005 11:16:51 -0600
User-agent: Mutt/1.5.6i


I have a user who recently reported a gawk problem to me.  He says that
his script used to work (gawk-3.1.1), but now does not work (gawk-3.1.3).
I looked into it, and I believe gawk is working as documented.  But what
I found was a change in behavior for the gawk regular expression extensions
between gawk-3.1.1 and gawk-3.1.3.

gawk-3.1.1: gawk treats \B as "the empty string not on a word boundry".
gawk-3.1.3: gawk treats \B as "the empty string within a word".

Here are a couple more data points.

- The regex files are totally different, and the ChageLog says that the regex
  files have been "synced to GLIBC source, maintaining K&R portability changes,
  and bug fixes.

- In both cases, gawk-3.1.1 and gawk-3.1.3, the man page says that \B matches
  "the empty string within a word"

I am writing you to make sure that you know about this change in behavior,
and to verify that the "new" behavior is the desired one.

I am adding his test case, just for your reference.

Thank you,


Tony Ernst


gawk '
        str = " [-a] "
        print str
        gsub(/\B\-+\w+(\-\w+)*/, "\\fB&\\fP", str)
        print str

Expected output (gawk-3.1.1 output):

gawk-3.1.3 output:

reply via email to

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