Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: combine two-part regex test

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


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
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (7)
As of 2024-03-29 09:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found