[Issue 5808] New: std.string.indexOf enhancement with start-at parameter
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Apr 3 11:56:51 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5808
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
AssignedTo: nobody at puremagic.com
ReportedBy: ruzicic.aleksandar at gmail.com
--- Comment #0 from Aleksandar Ruzicic <ruzicic.aleksandar at gmail.com> 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 =
CaseSensitive.yes);
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: https://gist.github.com/900589
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: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list