Add string:startswith(), endswith()

develop
lethosor 2016-04-16 17:13:41 -04:00
parent 8226134f67
commit b36193857c
1 changed files with 8 additions and 0 deletions

@ -247,6 +247,14 @@ function safe_index(obj,idx,...)
end
end
function string:startswith(prefix)
return self:sub(1, #prefix) == prefix
end
function string:endswith(suffix)
return self:sub(-#suffix) == suffix or #suffix == 0
end
-- String conversions
function dfhack.persistent:__tostring()