[Fredrik Lundh] > would "abc".find("", 100) == 3 be okay? or should we switch to treating the > optional start and end positions as "return value boundaries" (used to filter the > result) rather than "slice directives" (used to process the source string before > the operation)? it's all trivial to implement, and has no performance implications, > but I'm not sure what the consensus really is... FWIW, I like what you eventually did: >>> "ab".find("") 0 >>> "ab".find("", 1) 1 >>> "ab".find("", 2) 2 >>> "ab".find("", 3) -1 >>> "ab".rfind("") 2 >>> "ab".rfind("", 1) 2 >>> "ab".rfind("", 2) 2 >>> "ab".rfind("", 3) -1 I don't know that a compelling argument can be made for such a seemingly senseless operation, but the behavior above is at least consistent with the rule that a string of length n has exactly n+1 empty substrings, at 0:0, 1:1, ..., and n:n.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4