Android Question how can i remove invalid characters from a string text and convert string number to double ?

Waldemar Lima

Active Member
Licensed User
hi everyone !

i am trying convert this string to Double : "-50.601713��MyDoubleVal"

i am using this code to do it :

Dim TempVal As Double = StringInformation(2) ' here have double with string value
Log("My Double value is = "&TempVal)

but when i run this code i get this error : java.lang.NumberFormatException: Invalid double: "-50.601713��MyDoubleVal"
have a way to remove all string "��MyDoubleVal" from double ?
someone can help me ?


Well-Known Member
Licensed User
You can use Regex
    Dim d As String ="-50.601713��MyDoubleVal"
    Dim ma As Matcher
    ma = Regex.Matcher("(-?[0-9]+(?:[,.][0-9]+)?)",d)
    If ma.Find Then
    End If
Upvote 0