Using RegEx in extracting Data in a File

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • daveftl
    New Member
    • Jan 2007
    • 43

    Using RegEx in extracting Data in a File

    Hello,

    i've tried to extract certain data using Regex in a File. but it seems not working.No errors and warnings have been found.

    here is my code:
    Code:
    Private Sub extractTxt(ByVal inputFile As String)
            ' this  will extract specific text from a 
            ' file using Regular Expressions class in .net
            Dim DateRegEx As Regex
            Dim m As Match
            Dim i As Integer
    
            DateRegEx = New Regex("(?<month>[^/])/(?<day>[^/])/(?<year>)", RegexOptions.Multiline)
            For Each m In DateRegEx.Matches(inputFile)
                ListBox1.Items.Add(m.Groups("month").Value + "/" + m.Groups("day").Value + "/" + m.Groups("year").Value)
            Next
    
        End Sub
    
    =====
    the input of the function is a string that i read from a file using objreader.

    any help is appreciated...t hanks!
    Last edited by PRR; Apr 13 '09, 12:46 PM. Reason: Please post code in [code] [/code] tags.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Is your Regex expression correct?
    The best thing to do is test it on some sample input before using it.
    I'd try it out using a site like this one on a sample string (from your input file) to make sure it's working before proceeding.

    -Frinny

    Comment

    • daveftl
      New Member
      • Jan 2007
      • 43

      #3
      i guess so... buy many thanks for the link, at least i can check my RegEx first...

      thanks very much!

      Comment

      Working...