Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Extracting Text After <pre> tag in HTML

by mreece (Friar)
on Sep 22, 2006 at 20:28 UTC ( [id://574435]=note: print w/replies, xml ) Need Help??


in reply to Extracting Text After <pre> tag in HTML

if you want to do this with regular expressions, which is in most cases a bad idea (arguably unless you know the precise structure of your html, such as being darned certain there won't be nested or unmatched tags, etc) .. consider:
## OP specified 'last <pre>' tag, ## so assume there can be more than one <pre>..</pre> block ## find all <pre> blocks, using non-greedy .*? and also ## get \n in the case where the html ends with a newline and no </pre> ## anchor to non-capturing match for closing </pre> or end of string my @pre = ( $VAR1 =~ m{<pre>(.*?\n?)(?:</pre>|$)}isg ); ## we want the last one my $new_output = pop @pre;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://574435]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2024-04-24 16:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found