log files

Results 1 to 2 of 2

Thread: log files

  1. #1
    Join Date
    Dec 1969

    Default log files

    I'm trying to parse a NCSA log file in VB6. String operations being slow I'm trying to use RegEx instead. I'm just starting here since I'm a total beginner with RegEx. I want to first just split up each line of my log file. I tried this pattern .*(?=
    )<BR>But that gives me a newline character for every valid line. How should I change the pattern to just give me the contents of the line? Or am I going about this wrong?<BR><BR>If someone has already parsed NCSA log files and wishes to give me more advice beyond just this elementary first question, please go ahead!<BR><BR>Thanks, Harry.

  2. #2
    Join Date
    Dec 1969

    Default RE: log files

    I&#039;d recommend that for splitting the lines up you simply use the split() function.<BR>e.g.<BR>Dim arrLines<BR>arrLines = Split(logFileText, vbLf)<BR><BR>That&#039;ll give you an array of lines. Then you can tinker about with the lines to your heart&#039;s content. Of course, I&#039;ve never done this, and am assuming the split function is OK for multiline (don&#039;t see why it wouldn&#039;t be). I&#039;m also guessing that vbLf is the right vb constant: I hate the **** things, and can never remember them.<BR><BR>Remember that while RegEx&#039;s should be quick, they&#039;re actually doing a pretty complicated job. If you&#039;re not careful it&#039;s possible to get RegEx&#039;s that take exponential time to compute (due to the backtracking matching algorithms) -- the idiosyncratic one of these (nicked right out of the perlre manpage for perl) is:<BR>&#039;aaaaaaaaaaaa&#039; =~ /((a{0,5}){0,5})*[c]/<BR>Syntax is obviously all wrong for VB, but the idea works. So be careful!<BR><BR>Chris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts