lsyncd/mantle/string.lua

45 lines
748 B
Lua
Raw Normal View History

2018-03-30 13:15:49 +00:00
--
-- string.lua from Lsyncd -- the Live (Mirror) Syncing Demon
2018-03-19 07:50:29 +00:00
--
--
-- String comfort routines, also exported to user scripts.
--
--
-- This code assumes your editor is at least 100 chars wide.
--
-- License: GPLv2 (see COPYING) or any later version
-- Authors: Axel Kittenberger <axkibe@gmail.com>
--
if mantle
then
print( 'Error, Lsyncd mantle already loaded' )
os.exit( -1 )
end
--
-- Comfort routines, also for user.
-- Returns true if 'str' starts with 'start'
--
function string.starts
(
str,
start
)
return string.sub( str, 1, #start ) == start
end
--
-- Comfort routine, also for user.
-- Returns true if 'str' ends with 'ends'
--
function string.ends
(
str,
ends
)
return ends == '' or string.sub( str, -#ends ) == ends
end