You can add these two subs to implement LTrim and RTrim:
B4X:
Sub LTrim(s As String) As String
Dim m As Matcher = Regex.Matcher("^(\s+)", s)
If m.Find Then
Return s.SubString(m.GetEnd(1))
Else
Return s
End If
End Sub
Sub RTrim(s As String) As String
Dim m As Matcher = Regex.Matcher("(\s+)$", s)
If m.Find Then
Return s.SubString(m.GetEnd(1))
Else
Return s
End If
End Sub
Mike your code can be problematic if the string is long and there are many white spaces as each call to MyString.SubString will create a new string instance.
It is better to find the index of the last space (with Regex or any other way) and then call substring once.