exString is a collection of string related functions.
It's more properly documented on github, But here are some basics.
Import it:
Code: Select all
exString = require("exString")
Code: Select all
exString.import()
Code: Select all
str = exString.strip(str)
Code: Select all
str = str:strip()
Code: Select all
str = str:replace("something", "something else"):strip()
exString.startsWith(str, start) / exString.endsWith(str, end)
These return true if 'str' starts/ends with 'start'/'end'
exString.append(str, delimiter, ...)
This appends all arguments after the 'delimiter' to str then returns it. All arguments are tostring'd.
If delimiter is not false/nil, The appended strings will be seperated by it
Code: Select all
local str = "Hello"
str:append(false, " world", "!"):print()
> "Hello world!"
This one splits a string by 'delimiter', And collects the segments in a table. Then returns it. 'delimiter' defaults to ",". It doesn't seem to like it when you use "$" as a delimiter. I'm working on that.
Code: Select all
local str = "comma,seperated,string"
spl = str:split()
> {"comma", "seperated", "string"}
This one's inspired by python. It strips all leading & trailing whitespace & punctuation from str and returns it.
Code: Select all
local str = " hello!"
str:strip():print()
> "hello"
Yeah i'll be straight, This is just an alias for string.gsub. Even i don't use this one.
exString:print(str)
This is just an alias for print, But if you imported exString, You can call it directly on strings which i find neat
Code: Select all
str = "Hello world!"
str:print()
> "Hello world!"