Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Parse into array

by nagalenoj (Friar)
on Mar 12, 2009 at 04:11 UTC ( #750075=note: print w/ replies, xml ) Need Help??


in reply to Parse into array

This is just another way to solve your problem.

use strict; use warnings; while( <DATA> ) { foreach ( split "<b>" ) { # used .* since HTML code can be nested like <b><i>injury</i>< +/b> (my $name) = $_ =~ /(.*?)\<\/b\>/; print "$name\n" if ( defined( $name ) ); } } __DATA__ <td>Suggested Categories or Articles</td><td> <b><i>personal injury</i +></b> <font size="-3" face="Verdana"> (0.56)</font><br><b>accident la +wyers</b> <font size="-3" face="Verdana"> ( 0.4)</font><br><b>attorne +ys</b> <font size="-3" face="Verdana"> (0.35)</font><br><b>law firms< +/b> <font size="-3" face="Verdana"> (0.32)</font><br><b>litigation</b +> <font size ="-3" face="Verdana"> (0.32)</font><br></td>
The output will be like
<i>personal injury</i> accident lawyers attorneys law firms litigation


Comment on Re: Parse into array
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2014-09-16 03:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (155 votes), past polls