-
Notifications
You must be signed in to change notification settings - Fork 0
String library
Peter edited this page Dec 28, 2023
·
1 revision
The library inserts some helpful functions into the default string metatable, meaning you don't have to do anything to get them.
string.randomString(length: number, chars: nil|string[]) -> string
Creates a random string of given length
-
length
:number
- Length of string -
chars
:nil|string[]
- Optional. Charset for random characters, if not provided uses default:0-9,a-z,A-Z
-
string
str
- Random string of length from charset
string.cont(_str1, _str2) -> boolean
Checks if _str1
contains _str2
-
_str1
:string
- String to check in -
_str2
:string
- String to check for
-
boolean
contains
- If_str2
is in_str1
string.split(_str1, _sep) -> string[]
Splits _str1
on every occurrence of _sep
-
_str1
:string
- String to split -
_sep
:string
- String to split on
-
string[]
sections
- Sections of_str1
split around_sep
string.start(_str1, _str2) -> boolean
Checks if _str1
starts with _str2
-
_str1
:string
- String to check in -
_str2
:string
- String to check for
-
boolean
starts
- If_str1
starts with_str2
string.ends(_str1, _str2) -> boolean
Checks if _str1
ends with _str2
-
_str1
:string
String to check in -
_str2
:string
String to check for
-
boolean
ends
- If_str1
ends with_str2