Solved

# Regex Questions

Posted on 2006-05-10
189 Views
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
0
Question by:gr8life

LVL 17

Assisted Solution

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

LVL 14

Accepted Solution

Ok try this pattern

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

Author Comment

Thank you very much for all your expertise and time,
Gr8life
0

## Featured Post

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…