Check String for Non Numeric Characters Using Regular Expression

Posted: October 14, 2010 in ASP.Net

To check a string for non numeric characters, you can try the following:
ASP.Net (Code Behind)

' Routine to check if the street can be identifed as a apartment
Protected Function NonNumericCharacters(ByVal StrValue As String) As Boolean
    ' Declare variables
    Dim MyRegExpression As Regex = New Regex("[^0-9]")
    Dim ReturnValue As Boolean = False
    ' Check if there is non numeric parts in the string
    If MyRegExpression.IsMatch(StrValue) Then
        ReturnValue = True
        ReturnValue = False
    End If
    Return ReturnValue
End Function

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s