Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Extracting Text After <pre> tag in HTML

by mreece (Friar)
on Sep 22, 2006 at 20:28 UTC ( #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?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (1)
As of 2021-02-25 02:55 GMT
Find Nodes?
    Voting Booth?

    No recent polls found