How to extract all digits from string into another string using regex in VB.NET

1 Answer

0 votes
Imports System
Imports System.Text.RegularExpressions

Public Class Program
	Public Shared Sub Main()
		Dim str As String = "vb.net 1 java +746 c++ -2 c 3.14"
		
		Dim result As String = Regex.Replace(str, "[^\d]", "")
		
        Console.Write(result)
    End Sub
End Class

	
	
' run:
'
' 17462314
'

 



answered Jan 3, 2024 by avibootz
...