Skip to main content

String

This module provides utility functions for strings

Functions​

trim​

String.trim(
str: string,
pattern: string?--

Defaults to whitespace

) → string

Trims the string of the given pattern

toCamelCase​

String.toCamelCase(str: string) → string

Converts the string to UpperCamelCase from camelCase or snakeCase or YELL_CASE

uppercaseFirstLetter​

String.uppercaseFirstLetter(str: string) → string

Uppercases the first letter of the string

toLowerCamelCase​

String.toLowerCamelCase(str: string) → string

Converts to the string to lowerCamelCase from camelCase or snakeCase or YELL_CASE

toPrivateCase​

String.toPrivateCase(str: string) → string

Converts the string to _privateCamelCase

trimFront​

String.trimFront(
str: string,
pattern: string?--

Defaults to whitespace

) → string

Like trim, but only applied to the beginning of the setring

checkNumOfCharacterInString​

String.checkNumOfCharacterInString(
str: string,
char: string
) → number

Counts the number of times a char appears in a string.

note

Note that this is not UTF8 safe

isEmptyOrWhitespaceOrNil​

String.isEmptyOrWhitespaceOrNil(str: string) → boolean

Checks if a string is empty or nil

isWhitespace​

String.isWhitespace(str: string) → boolean

Returns whether or not text is only whitespace

elipseLimit​

String.elipseLimit(
str: string,
characterLimit: number
) → string

Converts text to have a ... after it if it's too long.

removePrefix​

String.removePrefix(
str: string,
prefix: string
) → string

Removes a prefix from a string if it exists

removePostfix​

String.removePostfix(
str: string,
postfix: string
) → string

Removes a postfix from a string if it exists

endsWith​

String.endsWith(
str: string,
postfix: string
) → boolean

Returns if a string ends with a postfix

startsWith​

String.startsWith(
str: string,
prefix: string
) → boolean

Returns if a string starts with a postfix

addCommas​

String.addCommas(
number: string | number,
seperator: string?
) → string

Adds commas to a number. Not culture aware.

Show raw api
{
    "functions": [
        {
            "name": "trim",
            "desc": "Trims the string of the given pattern",
            "params": [
                {
                    "name": "str",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "pattern",
                    "desc": "Defaults to whitespace",
                    "lua_type": "string?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 15,
                "path": "src/string/src/Shared/String.lua"
            }
        },
        {
            "name": "toCamelCase",
            "desc": "Converts the string to `UpperCamelCase` from `camelCase` or `snakeCase` or `YELL_CASE`",
            "params": [
                {
                    "name": "str",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 31,
                "path": "src/string/src/Shared/String.lua"
            }
        },
        {
            "name": "uppercaseFirstLetter",
            "desc": "Uppercases the first letter of the string",
            "params": [
                {
                    "name": "str",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 45,
                "path": "src/string/src/Shared/String.lua"
            }
        },
        {
            "name": "toLowerCamelCase",
            "desc": "Converts to the string to `lowerCamelCase` from `camelCase` or `snakeCase` or `YELL_CASE`",
            "params": [
                {
                    "name": "str",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 54,
                "path": "src/string/src/Shared/String.lua"
            }
        },
        {
            "name": "toPrivateCase",
            "desc": "Converts the string to _privateCamelCase",
            "params": [
                {
                    "name": "str",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 68,
                "path": "src/string/src/Shared/String.lua"
            }
        },
        {
            "name": "trimFront",
            "desc": "Like trim, but only applied to the beginning of the setring",
            "params": [
                {
                    "name": "str",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "pattern",
                    "desc": "Defaults to whitespace",
                    "lua_type": "string?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 78,
                "path": "src/string/src/Shared/String.lua"
            }
        },
        {
            "name": "checkNumOfCharacterInString",
            "desc": "Counts the number of times a char appears in a string.\n\n:::note\nNote that this is not UTF8 safe\n:::",
            "params": [
                {
                    "name": "str",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "char",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 94,
                "path": "src/string/src/Shared/String.lua"
            }
        },
        {
            "name": "isEmptyOrWhitespaceOrNil",
            "desc": "Checks if a string is empty or nil",
            "params": [
                {
                    "name": "str",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 107,
                "path": "src/string/src/Shared/String.lua"
            }
        },
        {
            "name": "isWhitespace",
            "desc": "Returns whether or not text is only whitespace",
            "params": [
                {
                    "name": "str",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 116,
                "path": "src/string/src/Shared/String.lua"
            }
        },
        {
            "name": "elipseLimit",
            "desc": "Converts text to have a ... after it if it's too long.",
            "params": [
                {
                    "name": "str",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "characterLimit",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 126,
                "path": "src/string/src/Shared/String.lua"
            }
        },
        {
            "name": "removePrefix",
            "desc": "Removes a prefix from a string if it exists",
            "params": [
                {
                    "name": "str",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "prefix",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 139,
                "path": "src/string/src/Shared/String.lua"
            }
        },
        {
            "name": "removePostfix",
            "desc": "Removes a postfix from a string if it exists",
            "params": [
                {
                    "name": "str",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "postfix",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 153,
                "path": "src/string/src/Shared/String.lua"
            }
        },
        {
            "name": "endsWith",
            "desc": "Returns if a string ends with a postfix",
            "params": [
                {
                    "name": "str",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "postfix",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 167,
                "path": "src/string/src/Shared/String.lua"
            }
        },
        {
            "name": "startsWith",
            "desc": "Returns if a string starts with a postfix",
            "params": [
                {
                    "name": "str",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "prefix",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 177,
                "path": "src/string/src/Shared/String.lua"
            }
        },
        {
            "name": "addCommas",
            "desc": "Adds commas to a number. Not culture aware.",
            "params": [
                {
                    "name": "number",
                    "desc": "",
                    "lua_type": "string | number"
                },
                {
                    "name": "seperator",
                    "desc": "",
                    "lua_type": "string?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 187,
                "path": "src/string/src/Shared/String.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "String",
    "desc": "This module provides utility functions for strings",
    "source": {
        "line": 5,
        "path": "src/string/src/Shared/String.lua"
    }
}