Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: My regex works, but I want to make sure it's not blind luck

by GrandFather (Saint)
on Dec 21, 2020 at 23:45 UTC ( [id://11125589]=note: print w/replies, xml ) Need Help??


in reply to My regex works, but I want to make sure it's not blind luck

Put it in a test script. Try it against edge cases (unusual test strings that might work when they shouldn't, or might not work when they should). For example:

use strict; use warnings; my @tests = ( ".", "", "A sentence.", ".gitignore", "word.doc", "a.dotted.name", ); print /^.*(\..*)$/ ? "Matched '$1' in " : "Failed", " '$_'\n" for @tes +ts;

Prints:

Matched '.' in '.' Failed '' Matched '.' in 'A sentence.' Matched '.gitignore' in '.gitignore' Matched '.doc' in 'word.doc' Matched '.name' in 'a.dotted.name'
Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-26 02:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found