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 instance 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.
newRegex
Creates a new regex instance.
Parameters:
pattern(String): The regex pattern.
Returns:
- (Regex): The regex instance.
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.