bug-gnu-utils
[Top][All Lists]
Advanced

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

word terminator


From: Pit Kreiner
Subject: word terminator
Date: Tue, 10 Apr 2001 10:15:21 +0200

The word terminators \< and \> seem to have a problem with _.
The following example shows what I mean:

file x.awk:

BEGIN {
        findvars [1] = "a_"
        replacevars [1] = "X"
        findvars [2] = "b"
        replacevars [2] = "Y"
        numberofvars = 2
}
{
        for (varindex = 1; varindex <= numberofvars; varindex++)
        {       actvar = findvars [varindex]
                if (actvar in replacemap)
                        actreplace = replacemap [actvar]
                else
                {
                        actreplace = replacevars [varindex]
                        replacemap [actvar] = actreplace
                }
                regexpr = "\\<" actvar "\\>"
                teststring = $0
                gsub (regexpr, actreplace)
                if (teststring == $0)
                        print "## error!"
        }
        print
}

file x.xxx:

a_ b
a_ b
a_ b
a_ b
a_ b
a_ b
a_ b

commandline:

awk -f x.awk x.xxx>x.nkv

problem:

The first 5 occurences of "a_" are not replaced by "X", the next 2 are. "b"
is always replaved by "Y".

--
   o  +   |   _  o   _     _
 o |_ |_  |< | e |_ | | e |  
|  Tel.:  +49-9131-7725-306



reply via email to

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