[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 |
Hi,
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
--
Tony Ernst
===================================================================
#!/bin/sh
gawk '
BEGIN {
str = " [-a] "
print str
gsub(/\B\-+\w+(\-\w+)*/, "\\fB&\\fP", str)
print str
}'
Expected output (gawk-3.1.1 output):
[-a]
[\fB-a\fP]
gawk-3.1.3 output:
[-a]
[-a]
- gawk regular expression extensions,
Tony Ernst <=