# Regex Questions

I'm currently using the code below to extract data.  I want to change the code to perform the same function except I need to exact data based on and IP address or a domain name. For example 61.1.1.1 or yahoo.com.  I don't need to have the application do both.  I just want to replace/modify this line when I need to change the search criteria.

Dim re As New Regex("^.*?Not\sin\sDatabase.*?$", RegexOptions.Multiline) 'working code below Imports System.Text.RegularExpressions Imports System.IO Dim re As New Regex("^.*?Not\sin\sDatabase.*?$", RegexOptions.Multiline)
Dim input As String = sr.ReadToEnd()
sr.Close()
Dim mc As MatchCollection
Dim sw As New StreamWriter("C:\resource\results.txt")

mc = re.Matches(input)
For Each m As Match In mc
sw.Write(m.Value)
Next
sw.Close()

Gr8life
###### Who is Participating?

Assoc Project ManagerCommented:
Ok try this pattern

Dim re As New Regex("[\w\-]+(\.[\w\-]+)+", RegexOptions.Multiline)
0

Commented:
From regexlib.com:  (you can test it here http://regexlib.com/RETester.aspx?regexp_id=1121 )

^((([hH][tT][tT][pP][sS]?|[fF][tT][pP])\:\/\/)?([\w\.\-]+(\:[\w\.\&%\$\-]+)*@)?((([^\s\<\>\\\"\.\,@;:]+)(\.[^\s\<\>\\\"\.\,@;:]+)*(\.[a-zA-Z]{2,4}))|((([01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}([01]?\d{1,2}|2[0-4]\d|25[0-5])))(\b\:(6553[0-5]|655[0-2]\d|65[0-4]\d{2}|6[0-4]\d{3}|[1-5]\d{4}|[1-9]\d{0,3}|0)\b)?((\/[^\/][\w\.\,\?\'\\\/\+&%\$#\=~_\-@]*)*[^\.\,\?\"\'!;<>{}\s\x7F-\xFF])?)\$

0

Author Commented:
Thank you very much for all your expertise and time,
Gr8life
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.