Best way to strip number out of string?

Hello all,

Other than using a loop looking at ascii values, what is the best way to strip a numeric value from a string?
For example I want to strip out the numbers from the string “comport1234”.
I can loop through the string character by character - or is there a better way? The IDE has many many new built in functions that I thought I would ask. I did look at the docs but did not see anything there that jumped out at me.

Thanks for your feedback!
Tim

You know… :slight_smile:

dim rx as new RegEx
rx.SearchPattern = "\\d+"
rx.ReplacementPattern = ""

dim rxOptions as RegExOptions = rx.Options
rxOptions.ReplaceAllMatches = true

dim replacedText as string = rx.Replace( sourceText )

RegEx…
That is new for me. Will have a look - Thank you Kem!
Tim

Kem’s regex method is by far the most efficient, but if you’re like me and are regex illiterate, a less efficient method but probably easier to understand is:

outputstring = inputstring
for i=0 to 9
  outputstring = ReplaceAll(outputstring,str(i),"")
next