Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
If you're sure of the table format...
while # use a loop to grab all instances (m| # use pipes to delimit, so no escaping / <tr # beginning of row .*? # minimal match of anything >(\d{5}) # > followed by 5 digits (remember digits) .*? # minimal match of anything >(\d{2}) # > followed by 2 digits (remember digits) .*? # minimal match of anything >(\d{3}) # > followed by 3 digits (remember digits) .*? # minimal match of anything >(\d{3}) # > followed by 3 digits (remember digits) .*? # minimal match of anything >(\d{2}) # > followed by 2 digits (remember digits) .*? # minimal match of anything (&nbsp;|\w) # &nbsp; or a letter </FONT> # followed by a closing font tag |isxg) { # case (i)nsensitive, treat as (s)ingle line, # e(x)tended comments, match (g)lobally (all) my @row = ($1,$2,$3,$4,$5,$6); # now do whatever with @row } # condensed while(m|<tr.*?>(\d{5}).*?>(\d{2}).*?>(\d{3}).*?>(\d{3}).*?>(\d{2}).*?( +&nbsp;|\w)</FONT>|isg) { my @row = ($1,$2,$3,$4,$5,$6); }
not tested, but I think it's OK :)

cLive ;-)


In reply to Re: Regex optimization by Anonymous Monk
in thread Regex optimization by deryni

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (6)
As of 2024-04-24 08:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found