Thread overview
[Issue 9103] New: find should work with multiple needles which are elements rather than ranges
Dec 02, 2012
Jonathan M Davis
Dec 02, 2012
Jonathan M Davis
Dec 02, 2012
Jonathan M Davis
December 02, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9103

           Summary: find should work with multiple needles which are
                    elements rather than ranges
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: jmdavisProg@gmx.com


--- Comment #0 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-12-02 01:12:50 PST ---
This code works:

import std.algorithm;

void main()
{
    string str = "hello world";
    str = find(str, "h", "j", "\n");
}

This code works:

import std.algorithm;

void main()
{
    string str = "hello world";
    str = find(str, 'h');
}

But this code doesn't:

import std.algorithm;

void main()
{
    string str = "hello world";
    str = find(str, 'h', 'j', '\n');
}

Currently, if you pass multiple needles to find, they must all be ranges. startsWith and endsWith will work with a combination of elements and ranges. find should do the same. And since the overload of find which takes multiple needles uses startsWith, it's that much more ridiculous that find doesn't work with a combination of ranges and elements like startsWith and endsWith do.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 02, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9103



--- Comment #1 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-12-02 01:57:06 PST ---
Actually, I mistyped (obviously I needed to actually compile all of the examples). Reassigning to str doesn't work for _any_ of these, because the result is a Tuple, but if you just replace str = with auto result =, then the ones where find compiles will compile.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 02, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9103



--- Comment #2 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-12-02 01:57:39 PST ---
https://github.com/D-Programming-Language/phobos/pull/988

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 02, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9103



--- Comment #3 from github-bugzilla@puremagic.com 2012-12-02 04:12:50 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/20341b4980365f2271d53a5202a76f587d080713 Implement issue# 9103.

find should work with multiple needles which are a combination of elements and ranges rather than just all ranges - just like startsWith and endsWith do - and since that overload of find calls startsWith, it's trivial to make it take the same types of arguments as startsWith.

https://github.com/D-Programming-Language/phobos/commit/a7b3164de1e7d637cd9e21eb5c981825acccf02d Merge pull request #988 from jmdavis/9103

Implement issue# 9103.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 02, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9103


Alex Rønne Petersen <alex@lycus.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |alex@lycus.org
         Resolution|                            |FIXED


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