Android Code Snippet Remove leading numbers from string

This code removes leading numbers from a string:

B4X:
sub RemoveLeadingNumbers(strIn as string) as string
  Return Regex.Replace("^[\d.]+\W+", strIn, "")
end sub



Test results:
B4X:
RemoveLeadingNumbers("10 Test20 -test30 /40 +50")    ' Test20 -test30 /40 +50
RemoveLeadingNumbers("Test20 -test30 /40 +50")       ' Test20 -test30 /40 +50
RemoveLeadingNumbers("10.12 Test20 -test30 /40 +50") ' Test20 -test30 /40 +50
RemoveLeadingNumbers("10,12 Test20 -test30 /40 +50") ' 12 Test20 -test30 /40 +50

Tags: strings, regex
 
Top