How To: Extract numbers from string
VB.NET
Shared Function ExtractNumbers( ByVal expr As String ) As String
Return String.Join( Nothing, System.Text.RegularExpressions.Regex.Split( expr, "[^\d]" ) )
End Function
C#
static string ExtractNumbers( string expr )
{
return string.Join( null,System.Text.RegularExpressions.Regex.Split( expr, "[^\\d]" ) );
}
Call the function as follows
VB.NET
Response.Write ( ExtractNumbers( "12EFR77" ) )
C#
Response.Write ( ExtractNumbers( "12EFR77" ) );