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
    Else
        ReturnValue = False
    End If
    Return ReturnValue
End Function
Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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