Category talk:Wren-str: Difference between revisions
→Source code: Added Str.lastIndexOf method.
(→Source code: Added support for wildcard matching to Str class.) |
(→Source code: Added Str.lastIndexOf method.) |
||
Line 375:
var ix = Str.indexOf(ss, search)
return (ix >= 0) ? start + ix : -1
}
// Returns the codepoint index (not byte index) at which 'search' last occurs in 's'
// or -1 if 'search' is not found.
static lastIndexOf(s, search) {
if (!(search is String)) Fiber.abort("Search argument must be a string.")
if (!(s is String)) s = "%(s)"
var l = s.toList
for (i in l.count-1..0) {
if (l[i] == search) return i
}
return -1
}
|