Just to give an idea of what I'm doing this is a line from the log:

2004-03-01 22:00:12 2 15.32.17.34 200 TCP_HIT 3140 326 GET http www.wahm.com http://www.wahm.com/images/vote.gif u779479 DEFAULT_PARENT 61.2.249.106 - "Mozilla/4.0 (compatible; MSIE 5.01; Windows 95)" OBSERVED none - 61.2.249.47 SG-HTTP-Service

And my regex is like this:

while (<>){ /(\S*\s*\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s +*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\". +*\")\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)/; #print "\n"; #printf "\ndate time = %s",$1; #printf "\ntime taken = %s",$2; #printf "\nc-ip = %s",$3; #printf "\nsc-status = %s",$4; #printf "\ns-action = %s",$5; #printf "\nsc-bytes = %s",$6; #printf "\ncs-bytes = %s",$7; #printf "\ncs-method = %s",$8; #printf "\ncs-uri-scheme = %s",$9; #printf "\ncs-host = %s",$10; #printf "\ncs-uri-stem = %s",$11; #printf "\ncs-username = %s",$12; #printf "\ns-hierarchy = %s",$13; #printf "\ns-supplier-name = %s",$14; #printf "\ncs(Content-Type)= %s",$15; #printf "\ncs(User-Agent) = %s",$16; #printf "\nsc-filter-result = %s",$17; #printf "\nsc-filter-category = %s",$18; #printf "\nx-virus-id = %s",$19; #printf "\ns-ip = %s",$20; #printf "\ns-sitename = %s",$21; }

Can you see whether a more explicit regex would speed the parse up?

Thanks,

js1.


In reply to Re^2: fast greedy regex by js1
in thread fast greedy regex by js1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.