function StringUtils.split(y,P)local X={}local C=1 if not P then for P=1,#y,1 do table.insert(X,string.sub(y,P,P))end return X end local D,U=string.find(y,P,C)while D do table.insert(X,string.sub(y,C,D-1))C=U+1 D,U=string.find(y,P,C)end table.insert(X,string.sub(y,C))return X end function StringUtils.trim(y)return y:match("\094\037\115\042\040\046-\041\037\115\042\036")end function StringUtils.startsWith(y,P)return string.sub(y,1,string.len(P))==P end function StringUtils.endsWith(y,P)return string.sub(y,-string.len(P))==P end function StringUtils.leftPad(y,P,X)return y.rep(X or" ",P-#y)..y end function StringUtils.rightPad(y,P,X)return y..y.rep(X or" ",P-#y)end return StringUtils

function StringUtils.split(str, delimiter) --: (string, string) => string
	local result = {}
	local from = 1
	if (not delimiter) then
		for i = 1, #str do
			table.insert(result, string.sub(str, i, i))
		end
		return result
	end
	local delim_from, delim_to = string.find(str, delimiter, from)
	while delim_from do
		table.insert(result, string.sub(str, from, delim_from - 1))
		from = delim_to + 1
		delim_from, delim_to = string.find(str, delimiter, from)
	end
	table.insert(result, string.sub(str, from))
	return result
end

function StringUtils.trim(s) --: (string) => string
	return s:match "^%s*(.-)%s*$"
end

function StringUtils.startsWith(str, start) --: (string, string) => boolean
	return string.sub(str, 1, string.len(start)) == start
end

function StringUtils.endsWith(str, ending) --: (string, string) => boolean
	return string.sub(str, -string.len(ending)) == ending
end

function StringUtils.leftPad(string, length, character) --: (string, number, string) => string
	return string.rep(character or " ", length - #string) .. string
end

function StringUtils.rightPad(string, length, character) --: (string, number, string) => string
	return string .. string.rep(character or " ", length - #string)
end

return StringUtils
