regexp:(g)sub buglet?

Michael McDaniel erlang@REDACTED
Tue Nov 29 18:12:03 CET 2005


On Tue, Nov 29, 2005 at 03:03:18PM +0500, Timur Irmatov wrote:
> On 11/29/05, Bengt Kleberg <bengt.kleberg@REDACTED> wrote:
> > On 2005-11-29 01:18, Hal Snyder wrote:
> >
> > > 3> regexp:gsub("foo","$","Z").
> > > {ok,"foo",0}
> >
> > before sam (http://plan9.bell-labs.com/sys/doc/sam/sam.html, first use
> > of strucural regular expressions) most (all?) regular expressions used
> > '\n' as end of string. try:
> >
> > regexp:gsub("foo\n","$","Z").
> 
> perl and python behave differently:
> 
> perl -e '$a="foo"; $a =~ s/$/Z/; print "$a\n"'
> 
> prints fooZ.
> 
> 
> --
> Timur Irmatov, xmpp:thor@REDACTED
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

from the regexp.html documentation on my R10B-8 system

"
^
    matches the beginning of a string.
$
    matches the end of a string. 
"

 ...


"To make these functions easier to use, in combination with the
 function io:get_line which terminates the input line with a new
 line, the $ characters also matches a string ending with "...\n".
 The following examples define Erlang data types:"


To me, the use of the phrase 
' ... also matches a string ending with "...\n". '  lead me to think
that "Z" should be appended in either case (with or without "\n" at
end of string).



~Michael



More information about the erlang-questions mailing list