www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - What should be reterned by std.array.replaceFirst

reply zhang <bitworld qq.com> writes:
I tested std.array.replaceFirst with the code belown:

    string s1 = "abc bcf";

    string s2 = s1.replaceFirst("bc", "ee");
    writefln("%s\n%s", s1, s2);

and got s2 is "aee". Should it be "aee bcf"?

Is it a bug, or just it is that?

Thanks.
----------
Zhang <bitworld qq.com>
Jul 29 2011
next sibling parent Jesse Phillips <jessekphillips+d gmail.com> writes:
On Sat, 30 Jul 2011 07:29:54 +0800, zhang wrote:

 I tested std.array.replaceFirst with the code belown:
 
     string s1 = "abc bcf";
 
     string s2 = s1.replaceFirst("bc", "ee"); writefln("%s\n%s", s1, s2);
 
 and got s2 is "aee". Should it be "aee bcf"?
 
 Is it a bug, or just it is that?
 
 Thanks.
 ----------
 Zhang <bitworld qq.com>

I'd say, bug file it. http://d.puremagic.com/issues/
Aug 01 2011
prev sibling parent zhang <bitworld qq.com> writes:
 On Sat, 30 Jul 2011 07:29:54 +0800, zhang wrote:
 
 I tested std.array.replaceFirst with the code belown:
 
     string s1 = "abc bcf";
 
     string s2 = s1.replaceFirst("bc", "ee"); writefln("%s\n%s", s1, s2);
 
 and got s2 is "aee". Should it be "aee bcf"?
 
 Is it a bug, or just it is that?
 
 Thanks.
 ----------
 Zhang <bitworld qq.com>

I'd say, bug file it. http://d.puremagic.com/issues/

Has filed a bug and offerd a patch, see here http://d.puremagic.com/issues/show_bug.cgi?id=6428 ---------- Zhang <bitworld qq.com>
Aug 02 2011