in reply to Re: regular expression to match specific members of a bus_name
in thread regular expression to match specific members of a bus_name
Thanks hippo.. I was not aware of the Test::More library, I do think that it works to explain what I was looking to do pretty well
I included the tests with the working and non working regex
#!/usr/bin/perl use strict; use warnings; use Test::More; my $regex = "/pce_rx_n1/"; like( "pce_rx_n1", $regex, "Matching my regex" ); like( "pce_rx_n1_blah", $regex, "Matching my regex" ); # #these fail because my $regex matches n1 and n10 and n13 # unlike( "pce_rx_n13", $regex, "Not Matching my regex" ); unlike( "pce_rx_n10_blah", $regex, "Not Matching my regex" ); #fix the regex with the #zero look-ahead negative assertion $regex = "/pce_rx_n1(?!\\d)/"; like( "pce_rx_n1", $regex, "Matching my regex" ); like( "pce_rx_n1_blah", $regex, "Matching my regex" ); unlike( "pce_rx_n12", $regex, "Not Matching my regex" ); unlike( "pce_rx_n10_blah", $regex, "Not Matching my regex" ); done_testing;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: regular expression to match specific members of a bus_name
by hippo (Archbishop) on Feb 12, 2016 at 13:37 UTC | |
by boleary (Scribe) on Feb 12, 2016 at 13:56 UTC |