String
The SD.String
module provides utility functions for string manipulation in Lua. This document details each function's purpose, parameters, return values, and usage examples.
String.StartsWith
SD.String.StartsWith(str, start)
SD.String.StartsWith(str, start)
Purpose: Checks if a string starts with a specified substring.
Parameters:
str
(string
): The string to check.start
(string
): The substring to match at the start ofstr
.
Returns:
(
boolean
): Returnstrue
ifstr
starts withstart
,false
otherwise.
Usage Example:
String.EndsWith
SD.String.EndsWith(str, ending)
SD.String.EndsWith(str, ending)
Purpose: Checks if a string ends with a specified substring.
Parameters:
str
(string
): The string to check.ending
(string
): The substring to match at the end ofstr
.
Returns:
(
boolean
): Returnstrue
ifstr
ends withending
,false
otherwise.
Usage Example:
String.CapitalizeFirst
SD.String.CapitalizeFirst(str)
SD.String.CapitalizeFirst(str)
Purpose: Capitalizes the first letter of a string and converts all other letters to lowercase.
Parameters:
str
(string
): The string to capitalize.
Returns:
(
string
): The string with the first letter capitalized and all subsequent letters in lowercase.
Usage Example:
String.Split
SD.String.Split(str, delim)
SD.String.Split(str, delim)
Purpose: Splits a string into a table of substrings based on a specified delimiter.
Parameters:
str
(string
): The string to split.delim
(string
): The delimiter to use for splitting the string.
Returns:
(
table
): A table containing the substrings derived from splittingstr
bydelim
.
Usage Example:
Last updated