in reply to Re^2: regular expression to match specific members of a bus_name
in thread regular expression to match specific members of a bus_name
Thank you - that is much clearer. Here is your code with only the first regex changed and it now passes all the tests. HTH, Hippo.
#!/usr/bin/perl use strict; use warnings; use Test::More; my $regex = qr/pce_rx_n1\D*$/; 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^4: regular expression to match specific members of a bus_name
by boleary (Scribe) on Feb 12, 2016 at 13:56 UTC |