Fork me on GitHub

str.bytes(s:string):table

returns a table with the byte of every string's character

str.camel_case(s:string):string

converts string to `camel case`

str.capitalize(s:string):string

returns a new string with the first character converted to uppercase and the remainder to lowercase

str.center(s:string,n:number):string

returns a copy of the string passed as parameter centralized with spaces passed in size parameter

str.count(s:string,substr:string):number

returns how many times the substring was found

str.delete(s:string,chars:table):table

returns a copy of the string passed by parameter without the specified characters

str.each_byte(s:string,callback:function):void

passes every byte in string to the given function

str.each_char(s:string,callback:function):void

executes a provided function once for each character of the string

str.each_line(s:string,callback:function):void

executes a provided function once for each line of the string

str.ends_with(s:string,finish:number):string

checks whether string ends with the value passed by parameter

str.escape(s:string):string

converts the characters "&", "<", ">", '"', and "'" in string to their corresponding html entities.

str.find_last(s:string,match:string):table

returns nil if the value is not found

str.includes(s:string,substr:string):boolean

determines wether the substring was found within the string

str.index_of(s:string,substr:string):number

returns the position of the first occurrence of a specific substring

str.is_ascii(s:string):boolean

checks whether the string has only ascii characters

str.is_number(s:string):boolean

checks whether the string has only numbers characters

str.kebab_case(s:string):string

converts string to `kebab case`

str.replace(s:string,substr:string,new_substr:string):number

returns a new string replacing the specific values from the original string

str.slice(s:string,start:number,finish:number | nil):string

extracts a part of the string and returns a new string

str.slug(s:string):string

converts string to slug and returns it as a new string

str.snake_case(s:string):string

converts string to `snake case`

str.split(s:string,pattern:string):table

splits the string into substring using the specified separator and return them as a table

str.starts_with(s:string,start:number):string

checks whether string starts with the value passed by parameter

str.trim(s:string):string

returns a copy of string leading and trailing whitespace removed

str.trim_left(s:string):string

returns a new string with leading whitespace removed

str.trim_right(s:string):string

returns a new string with trailing whitespace removed

str.truncate(s:string,options:table):table

truncates string if it's longer than the given maximum size

str.unescape(s:string):string

converts the HTML entities `&amp;`, `&lt;`, `&gt;`, `&quot;` and `&#39;` in string to their corresponding characters.