[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Oddity in regular expressions
From: |
Andrew Koenig |
Subject: |
Oddity in regular expressions |
Date: |
Fri, 13 Apr 2001 10:20:29 -0400 (EDT) |
Here's a program:
BEGIN {
s = "[::]"
print "Before: " s
gsub(/\[/, "\\\\&\\f(CW", s)
print "After: " s
}
Running under GNU Awk 3.0.6 yields this output:
Before: [::]
After: \[\f(CW::]
Running under AT&T awk yields this output
Before: [::]
After: \&\f(CW::]
The problem appears to be that GNU Awk is treating the & as
a regular-expression replacement character even though it is
preceded by a backslash.
I can see the point -- it view the replacement as \ \ & \ f ( CW
and treats the \ \ as an escaped backslash. Nevertheless, it's
an incompatibility with the original.
Is this an intentional incompatibility, or a bug?
--
Andrew Koenig, address@hidden, http://www.research.att.com/info/ark
-=- MIME -=-
This is a MIME-encapsulated message.
--308004CE05.987171428/mail-blue.research.att.com
Content-Description: Notification
Content-Type: text/plain
This is the Postfix program at host mail-blue.research.att.com.
I'm sorry to have to inform you that the message returned
below could not be delivered to one or more destinations.
For further assistance, please contact <address@hidden>
If you do so, please include this problem report. You can
delete your own text from the message returned below.
The Postfix program
<address@hidden>: Name service error for domain gnu.org: Host found but no
data record of requested type
--308004CE05.987171428/mail-blue.research.att.com
Content-Description: Undelivered Message
Content-Type: message/rfc822
Received: from europa.research.att.com (europa.research.att.com
[135.207.23.117])
by mail-blue.research.att.com (Postfix) with ESMTP id 308004CE05
for <address@hidden>; Fri, 13 Apr 2001 10:17:08 -0400 (EDT)
Received: (from address@hidden)
by europa.research.att.com (8.8.8/8.8.7) id KAA02813;
Fri, 13 Apr 2001 10:17:07 -0400 (EDT)
Date: Fri, 13 Apr 2001 10:17:07 -0400 (EDT)
Message-Id: <address@hidden>
X-Authentication-Warning: europa.research.att.com: ark set sender to
address@hidden using -f
From: Andrew Koenig <address@hidden>
To: address@hidden
Subject: Oddity in regular expressions
Here's a program:
BEGIN {
s = "[::]"
print "Before: " s
gsub(/\[/, "\\\\&\\f(CW", s)
print "After: " s
}
Running under GNU Awk 3.0.6 yields this output:
Before: [::]
After: \[\f(CW::]
Running under AT&T awk yields this output
Before: [::]
After: \&\f(CW::]
The problem appears to be that GNU Awk is treating the & as
a regular-expression replacement character even though it is
preceded by a backslash.
I can see the point -- it view the replacement as \ \ & \ f ( CW
and treats the \ \ as an escaped backslash. Nevertheless, it's
an incompatibility with the original.
Is this an intentional incompatibility, or a bug?
--
Andrew Koenig, address@hidden, http://www.research.att.com/info/ark
--308004CE05.987171428/mail-blue.research.att.com--
- Oddity in regular expressions,
Andrew Koenig <=