'Trims n letters from the right side of the string.
Public Sub TrimRight(s As String, amnt As Int) As String
If amnt > s.Length Then Return s
Return s.SubString2(0, s.Length - 1 - amnt)
End Sub
'Trims n letters from the left side of the string.
Public Sub TrimLeft(s As String, amnt As Int) As String
If amnt > s.Length Then Return s
Return s.SubString2(amnt, s.Length)
End Sub
'Repeats n times the given string.
Public Sub Repeat(Text As String, nTimes As Int) As String
Dim s As StringBuilder : s.Initialize
For i = 1 To nTimes
s.Append(Text)
Next
Return s.ToString
End Sub
'Counts the number of times the text is present in the string.
Public Sub CountOccurence(Text As String, Character As String) As Int
Dim i As Int = 0
Dim index As Int = -1
Do While True
index = Text.IndexOf2(Character, index +1)
If index = -1 Then Exit
i = i +1
Loop
Return i
End Sub
'Returns true if the regular expression is present in the string.
Public Sub ContainsRegex(Pattern As String, Text As String, CaseSensitive As Boolean) As Boolean
Dim m As Matcher
If CaseSensitive Then
m = Regex.Matcher(Pattern, Text)
Else
m = Regex.Matcher2(Pattern, Regex.CASE_INSENSITIVE, Text)
End If
Return m.Find
End Sub