[Top][All Lists]

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

[bug-gawk] Issue #Q5: regexp: gsub: symbol `&' in replacement parameter

From: Denis Shirokov
Subject: [bug-gawk] Issue #Q5: regexp: gsub: symbol `&' in replacement parameter
Date: Tue, 6 Nov 2012 16:25:21 +0200


Another strange regexp issue:

If character `&' is present in parameter `replacement' of gsub
function, then this character will be replaced by string that actually
matches to regular expression:

>gawk --version
GNU Awk 4.0.1
Copyright (C) 1989, 1991-2012 Free Software Foundation.

>type Q5.gwk

        print "`" a "'"
        print "`" a "'" }

>gawk -f Q5.gwk

(file Q5.gwk attached)

As you can see - string `cd' matched by regular expression /cd/ was
been replaced by `CcdDcdZ' - not by `C&D&Z'.
It looks like this symbol has some special meaning in replacement string.

If this is `by design' then what else characters have special
meanings? Is there a way to work in GSUB with parts of matched strings
like in gensub function?

Attachment: Q5.gwk
Description: Binary data

reply via email to

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