Solved

RegEx

Posted on 2008-06-19
2
223 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
ID: 21828785
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
ID: 21832090
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

914 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

15 Experts available now in Live!

Get 1:1 Help Now