Menu

#42 escaping 7 in replacement string does not work properly

open
nobody
None
5
2009-05-20
2009-05-20
Anonymous
No

Escaping & in replacement string for gsub and sub does not work properly. I have to write 4 backslashes to get awka to print a literal &. Also if I write \& it will replace it with a number instead of the replacement string. Other than an ugly replacement string, this is also not compatible with gnu awk which will output \& instead of &. In case awka is not installed I default to gawk so it would be very nice if this could be fixed.

Code looks like this:
gsub( /&/, "\\\\&", $i ); awka: & gawk: \&
gsub( /</, "\\\\&lt;", $i ); awka: &lt; gawk: \&lt;
gsub( />/, "\\\\&gt;", $i ); awka: &gt; gawk: \&gt;

version used is 0.7.5

Discussion


Log in to post a comment.

MongoDB Logo MongoDB