0

Hi All,
can anyone give me the regx expression to be used to search for ip address in microsoft visual studio versions. If I open text files using Visual studio and ctrl+Shift+F, search al open documents, then give the regex, it should list all the ipaddress contained lines at the bottom.The ip address I consider is any four numbers seperated by three dots. Eachnumber contains maximum three digits and minimum 1 digit.

it can be 0.0.0.0 or 127.0.0.1 etc.
Please give me the regex.

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Jx_Man
0

see if this help :

Public Function IsValidIP(ByVal addr As String) As Boolean
    'create our match pattern
    Dim pattern As String = "^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\." & _
    "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$"
    'create our Regular Expression object
    Dim check As New Text.RegularExpressions.Regex(pattern)
    'boolean variable to hold the status
    Dim valid As Boolean = False
    'check to make sure an ip address was provided
    If addr = "" Then
        'no address provided so return false
        valid = False
    Else
        'address provided so use the IsMatch Method
        'of the Regular Expression object
        valid = check.IsMatch(addr, 0)
    End If
    'return the results
    Return valid
End Function
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.