[Issue 3786] bug in std.string.removechars

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Feb 9 18:50:31 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3786



--- Comment #1 from Igor Lesik <curoles at yahoo.com> 2010-02-09 18:50:30 PST ---
Just in case, the correct version of the function might look like:

string removechars(string s, in string pattern)
{
    char[] r;
    bool changed = false;

    foreach (size_t i, dchar c; s)
    {
        if (inPattern(c, pattern)){
                if (!changed)
                {   changed = true;
                    r = s[0 .. i].dup;
                }
                continue;
        }
        if (changed)
        {
            std.utf.encode(r, c);
        }
    }
    return (changed? r.idup : s);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list