Solved

RegEx

Posted on 2008-06-19
2
227 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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 …

739 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