Adding `string.startswith()` and `string.endswith()`
Closed this issue · 1 comments
s-hadinger commented
@skiars Are you ok to add:
string.startswith(hay:string, needle:string [, case_insensitive:bool]) -> bool
string.endswith(hay:string, needle:string [, case_insensitive:bool]) -> bool
After writing some decent amount of code, it is quite common to have to check if a string starts or ends with a specific value. The current way to do it are not straightforward:
startswith
(case sensitive):
def startswith(hay, needle)
import string
return string.find(hay, needle) == 0
end
endswith
is not as straightforward to implement, and both lack case-insensitive check which would be useful for file extensions.
skiars commented
This is very necessary.