Kenpali Text Specification
Editing Strings
trim
Removes all whitespace from the start and end of the string.
Parameters:
string(string): The string to trim.
Returns:
- (string): The trimmed string.
toLowerCase
Converts all letters to lowercase.
Parameters:
string(string): The string to convert to lowercase.
Returns:
- (string): The lowercase string.
toUpperCase
Converts all letters to uppercase.
Parameters:
string(string): The string to convert to uppercase.
Returns:
- (string): The uppercase string.
startsWith
Tests whether the string starts with the specified prefix.
Parameters:
string(string): The string to check.prefix(string): The prefix to check for.
Returns:
- (boolean): Whether
stringstarts withprefix.
removePrefix
Removes the specified prefix from the string if possible.
Parameters:
string(string): The string to remove the prefix from.prefix(string): The prefix to remove.
Returns:
- (string): If
stringstarts withprefix,stringwithprefixremoved, otherwisestringitself.
endsWith
Tests whether the string ends with the specified suffix.
Parameters:
string(string): The string to check.suffix(string): The suffix to check for.
Returns:
- (boolean): Whether
stringstarts withsuffix.
removeSuffix
Removes the specified suffix from the string if possible.
Parameters:
string(string): The string to remove the suffix from.suffix(string): The suffix to remove.
Returns:
- (string): If
stringstarts withsuffix,stringwithsuffixremoved, otherwisestringitself.
Regular Expressions
regex
Creates a regex object to match the specified regex pattern.
Some regex methods return match objects. A match object has the following properties:
match(string): The portion of the string that matched the regex.index(number): The index in the string where the match starts.numberedGroups(array of string): The substrings matched by the numbered groups in the regex.namedGroups(object of string): The substrings matched by the named groups in the regex.
Parameters:
pattern(string): The regex pattern.
Returns:
- (object): The regex object.
regex/findAll
Finds all matches for the regex in the specified string.
Parameters:
string(string): The string to search.
Returns:
- (array of object): An array of all the match objects.
regex/match
Tries to match the regex against an entire string.
Parameters:
string(string): The string to match.
Returns:
- (object or null): A match object if the entire string matches the regex, or
nullif it doesn’t.