Solved

RegEx

Posted on 2008-06-19
2
222 Views
Last Modified: 2010-04-23
How can I use Reg Expression to check a line if contain an IP address?
0
Comment
Question by:VBdotnet2005
2 Comments
 
LVL 7

Assisted Solution

by:DarkHill
DarkHill earned 100 total points
Comment Utility
Got this off the xenocafe.com site, let me know if it works for you:

Private Function isIP(ByVal ip As String) As Boolean
    Dim regex As New RegularExpressions.Regex("^(?:(?:25[0-5]|2[0-4]\d|[01]\d\d|\d?\d)(?(\.?\d)\.)){4}$")
    Return regex.IsMatch(ip)
End Function
0
 
LVL 27

Accepted Solution

by:
planocz earned 150 total points
Comment Utility
darkhill  has it.
but this looks better.
Imports System.Text.RegularExpressions

 Private Function isIP(ByVal ip As String) As Boolean
        ' Return true if ip is in valid ip address format.
        Return Regex.IsMatch(ip, ("^(?:(?:25[0-5]|2[0-4]\d|[01]\d\d|\d?\d)(?(\.?\d)\.)){4}$"))
    End Function
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now