Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: regex help required

by locked_user sundialsvc4 (Abbot)
on Jun 24, 2013 at 13:16 UTC ( [id://1040437]=note: print w/replies, xml ) Need Help??


in reply to regex help required

Indeed.   You must not only determine what it is you do want to match (hence the reply #1:   “what are the relevant parts?”), but also what rules will filter out what you do not want.

Seriously consider using a subroutine to allow for some conditional logic to be used ... (pseudocode follows)

sub my_filter { my $str = shift; my $TRUE = 1; my $FALSE = 0; # FOR CLARITY return $FALSE if ($str =~ /reject_pattern_#1/); return $FALSE if ($str =~ /reject_pattern_#2/); return $TRUE if ($str =~ /accept_pattern_#1/); return $TRUE if ($str =~ /accept_pattern_#2/); return $FALSE; // DOESN'T MATCH ANYTHING }

Then, write a test-program using Test::More which puts your subroutine through many dozens of tests, using a carefully-chosen set of “correct,” “almost correct,” “barely incorrect” and “outright bogus” strings, to prove that your logic is actually trustworthy and reliable.   (Tip:   you will spend a lot more time ferreting-out the little bugs that were lurking in your original version, hoping to remain un-detected, than you originally thought possible.)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2026-02-18 20:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    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.