Although I am far too lazy to check with my oreilly right now I would hazard a guess that ".*" is the crucial point. Matching something like "chr.*?\s" should be fairly easy. Discard anything that does not look like "chr" if you find something that looks like it. See if the next thing is a \s else get whatever it is and look if the thing after that thing is a \s. In comparison looking for ".*" is more expensive as that .* tries to grap as much as possible and it has to play through all the possible combinations to see if it cann match something more. It could be summarized like "Matching greedy things is more expensive than matching non greedy things" Is that understandable (I do hope it is right somewhat ;) ? Regards Hexren

In reply to Re: Regex, capturing variables vs. speed by Hexren
in thread Regex, capturing variables vs. speed by albert

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.