A String library for lua
LuaLibs is a string library for Lua that provides utility functions for string operations
The project is hosted on GitHub. You can report bugs and discuss features on the issues page, or email to amstel91@gmail.com.
The tests are available in test folder
local strl = require "strl"
strl.isString(value)
returns true if the given value is a String else returns false
strl.isString("Hello")
=> true
strl.isString(4)
=> false
strl.isEmpty(value)
returns true if value is nil or empty string
strl.isEmpty("Hello")
=> false
strl.isEmpty("")
=> true
strl.isEmpty(nil)
=> false
strl.trim(value)
returns trims leading and trailing whitespaces
strl.trim(" Hello ")
=> Hello
strl.ltrim(value)
returns trims leading whitespaces
strl.ltrim(" Hello")
=> Hello
strl.rtrim(value)
returns trims trailing whitespaces
strl.rtrim("Hello ")
=> Hello
strl.split(value,[seperator])
returns a table of string split using the seperator. By default space is the seperator
strl.split("Hello World")
=> {"Hello","World"}
strl.split("Hello-World","-")
=> {"Hello","World"}
strl.splitLines(value)
returns a table of string split by line
strl.splitLines("Hello\nWorld")
=> {"Hello","World"}
strl.startsWith(value,startsWithValue)
returns true if the first parameter starts with the second paramter.
strl.startsWith("HelloWorld","Hello")
=> true
strl.startsWith("HelloWorld","World")
=> false
strl.endsWith(value,endsWithValue)
returns true if the first parameter ends with the second paramter.
strl.endsWith("HelloWorld","World")
=> true
strl.endsWith("HelloWorld","Hello")
=> false
strl.encodeBase64(value)
returns base 64 encoded string
strl.encodeBase64("test:test123")
=> "dGVzdDp0ZXN0MTIz"
strl.decodeBase64(value)
returns base 64 decoded string
strl.decodeBase64("dGVzdDp0ZXN0MTIz")
=> "test:test123"