StringUtils
countMatches
Returns count of pattern matches.
Example
print(StringUtils.countMatches("the quick brown fox jumps over the lazy dog", "the"))
2
matches
Returns matches in a table with where the match starts and ends.
Example
print(StringUtils.matches("the quick brown fox jumps over the lazy dog", "the"))
{
{
End = 3,
Match = "the",
Start = 1
},
{
End = 34,
Match = "the",
Start = 32
}
}
replace
Splices a new string into an existing string.
Example
print(StringUtils.replace("the quick brown fox jumps over the lazy dog", "red cat", 11, 19))
the quick red cat jumps over the lazy dog
collapse
Replaces sequential pattern occurances with a single occurance. This is useful to remove double spaces in chat messages.
Example
print(StringUtils.collapse(" i am spamming chat", " "))
There is still a space at the start of the string.
i am spamming chat
hash
Uses the bytes in a string to generate a hash.
Example
print(StringUtils.hash("the quick brown fox jumps over the lazy dog"))
67114530
reverseSub
Similar to string.sub()
but instead starts at the end of a string instead of the front.
Example
print(StringUtils.reverseSub("the quick brown fox jumps over the lazy dog", 1, 8))
lazy dog