RegEx replace

I’m trying to use RegEx to clean a string and remove all NON-DIGIT chars.
The test code below return 230818A instead 230818.

Dim re As New RegEx
re.SearchPattern = "\\D"
re.ReplacementPattern = ""
re.Options.ReplaceAllMatches = true

Dim text As String = "230818ABC"

Dim match As RegExMatch = re.Search(text)
If match <> Nil Then
  text = re.Replace()
End If

MsgBox(text)

Setting text=ABC230818ABC, the code return A230818

What’s wrong?

Sadly, you fell into a trap that has tripped me up more than once. You don’t need to Search before you Replace, so that Search is leaving you with the first non-digit it finds, because Replace will pick up with the character after. Do this instead:

Dim re As New RegEx
re.SearchPattern = "\\D"
re.ReplacementPattern = ""
re.Options.ReplaceAllMatches = true

Dim text As String = "230818ABC"

text = re.Replace(text)

MsgBox(text)

Many thanks.
Without search, works fine.