Summary: std.string.indexOf enhancement with start-at parameter
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos

--- Comment #0 from Aleksandar Ruzicic <> 
2011-04-03 20:53:13 CEST ---
Other languages/libraries have start_index as an optional parameter used to
start search at, in their versions of indexOf function.

currently, signature of indexOf is:

sizediff_t indexOf(Char)(in Char[] s, dchar c, CaseSensitive cs =

and desired is:

sizediff_t indexOf(Char)(in Char[] s, dchar c, CaseSensitive cs =
CaseSensitive.yes, sizediff_t sp = 0);

where sp stands for "starting position" and is from where search will start.
Negative indices -N should also be allowed to be able to search a char only in
last N characters of the string.

Example implementation of this parameter (it's really simple addition) can be
found here:
Note: if this gets copied to Phobos without changing, it must be properly
tested, since I wrote it just as a quick example...

Also, it would be great if this variation of indexOf template is added (which
can be seen in the gist link above):

sizediff_t indexOf(Char, T = sizediff_t)(in Char[] s, dchar c, T sp = 0)
if (isSomeChar!Char)
    return indexOf(s, c, CaseSensitive.yes, sp);

since it allows to skip case sensitivity parameter when not needed (which is
mostly the case).

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to