in reply to [Solved]: Query about regular expression
#!/usr/bin/perl # http://perlmonks.org/?node_id=1142838 use strict; use warnings; $| = 1; $_ = join '', <DATA>; my ($fourth) = /(?:.*?<li>(.*?)<\/li>){4}/s; print "$fourth\n"; __DATA__ <ul> <li><strong>site_user</strong></li> <ul> <li>user1</li> </ul> <li><strong>compare_hidden</strong></li> <ul> <li>average_speed_answer 25 60 30 60 ^M<br /> calls_waiting 300 500 300 500 ^M<br /> many more rows here post_ivr_calls_handled Wisconsin 50 100 50 100 ^M<br /> post_ivr_calls_handled Wyoming 50 100 50 100 ^M<br /> </li> <li><strong>calls_waiting_good_high</strong></li> <ul> <li>300</li> </ul> <li><strong>calls_waiting_warning_low</strong></li> <ul>
Of course, this will have problems if you have nested li's
|
|---|