Link to home
Start Free TrialLog in
Avatar of gr8life
gr8life

asked on

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 sr As New StreamReader("C:\resource\input.txt")
        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()

Thank you in advance for your time and expertise,
Gr8life
SOLUTION
Avatar of ZeonFlash
ZeonFlash

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gr8life
gr8life

ASKER

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