I have a module that takes a regular expression as part of a config file. It parses a web page and tries to locate a specific link based on the date. One particular page happens to use tables making this difficult. An example page might look like:

<TABLE> <TD><A HREF="/yesterday"><IMG ...></a></td> <TD>5-2-2001</td> <TD><A HREF="/today"><IMG ...></a></td> <TD>5-3-2001</td> </table>

Initially I tried to use m|A HREF="(.*?)">.*?5-3-2001|igs; This works, but not quite the way I want. The problem is, no matter the date given, it always finds the first HREF. I've read over the perlre docs and figured out why it does this, but I can't figure out how to do what I want without using special code

And that, of course, is the other complication. As I said above, I'm trying to use a system I wrote that reads the RE from a config file. I don't want to have to write code specifically for this one instance...I'd rather be able to handle it with the one RE in the config file. Any ideas, or do I just have to suck it up and write code to do this kind of thing?


In reply to Complicated(?) RE help by Anonymous Monk

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.