How to move the digits of a string with digits and letters to the beginning of the string in VB.NET

1 Answer

0 votes
Imports System
Imports System.Text.RegularExpressions

Class Program
	Public Shared Sub Main()
        Dim inputString As String = "d2c54be3a1"
        Dim output As String = MoveDigitsToFront(inputString)
		
        Console.WriteLine(output)
    End Sub

    Private Shared Function MoveDigitsToFront(ByVal input As String) As String
        Dim digits As String = Regex.Replace(input, "\D", "")
        Dim nonDigits As String = Regex.Replace(input, "\d", "")
		
        Return digits & nonDigits
    End Function
End Class
		


' run
'
' 25431dcbea
'

 



answered May 27 by avibootz
...