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

Re: How to Ask a Regex Question (with Test::More) (repost, with Sitedocclan approval)

by Eimi Metamorphoumai (Deacon)
on Aug 08, 2005 at 15:39 UTC ( #481916=note: print w/ replies, xml ) Need Help??


in reply to How to Ask a Regex Question (with Test::More) (repost, with Sitedocclan approval)

My problem with this template is that what regex is needed is usually defined as much by what strings it should not match as by what it should. Also, when it does match, how. So it would be very nice if the test harness let you say "the string 'timmytimmers@aol.com' should match with $1 eq 'timmytimmers' and $2 eq 'aol.com' but the string 'herbill.gerbil.org!garygerbil' shouldn't match at all". Otherwise, the correct answer is always /.*/.


Comment on Re: How to Ask a Regex Question (with Test::More) (repost, with Sitedocclan approval)
Select or Download Code
Re^2: How to Ask a Regex Question (with Test::More) (repost, with Sitedocclan approval)
by eric256 (Parson) on Aug 08, 2005 at 17:13 UTC

    I assumed that Test::More would have this in the bag, but went ahead and checked. Test::More certainly handles this already with an unlinke($this, $regex). This should probably be mentioned in the template (which I'm sure is what you meant.) As for matching HOW it matched, that would be an interesting problem. Perhaps a the test harness should accept an arrayref where the first element is the regex and the following should be $1..$9 in order?

    like("Hello World", [ /(.+)\s(.+)/, "Hello", "World"]);

    Seems like a mouth full but it would handler your case.

    Just my two cents.


    ___________
    Eric Hodges

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (12)
As of 2014-09-19 13:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (138 votes), past polls