Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Just another Perl shrine
 
PerlMonks  

Re: combine two-part regex test

by AltBlue (Chaplain)
on Jan 29, 2007 at 19:24 UTC ( [id://597229]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to combine two-part regex test

fancy experimental features? ;-)
#!/usr/bin/perl -l use strict; use warnings; my @str = split /\n/, <<'HTML'; <tr class="meld"><th>Security Code Matched</th><td>foo</td></tr> <tr><th>Security Code Matched</th><td>N/A</td></tr> <tr><th class="foo">Security Code Matched</th><td>N/A</td></tr> <tr><th>Security Code Matched</th><td>10!</td></tr> <tr><td>Security Code Matched</td><td class="val">N/A</td></tr> HTML for (@str) { if ( m{ \bSecurity\ Code\ Matched\b (.*?)</tr> (?(?{ index($^N, 'N/A') < 0 })!) }xsg ) { print "[[$_]]"; } }
output:
[[<tr><th>Security Code Matched</th><td>N/A</td></tr>]] [[<tr><th class="foo">Security Code Matched</th><td>N/A</td></tr>]] [[<tr><td>Security Code Matched</td><td class="val">N/A</td></tr>]]
i wouldn't use it at home, though ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://597229]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.