josh803316 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; my $tests = [ 'ONT |Status |% Complete ----|--------------------|---------- 1.1 |activate complete |100 1.2 |activate complete |100 1.3 |activate complete |100 1.4 |activate complete |100 2.1 |activate complete |100 2.2 |activate complete |100 2.3 |activate failed |100 2.4 |activate complete |100 ' ]; # Negative check....should pass as long as the word failed is not in t +he text string my $regex = '^((?!failed).)*$'; #my $regex = 'ONT.*activate failed.*$'; foreach my $test (@$tests) { if($test =~ qr{$regex}ms) { print "$test\n REGEX MATCHED\n"; } else { print "$test\n REGEX DID NOT MATCH!\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Multi-line string regex and negative inline match
by ikegami (Patriarch) on Jul 30, 2010 at 21:46 UTC | |
by josh803316 (Beadle) on Jul 30, 2010 at 22:31 UTC | |
by ahmad (Hermit) on Jul 30, 2010 at 23:34 UTC | |
by ikegami (Patriarch) on Jul 31, 2010 at 00:26 UTC | |
by ahmad (Hermit) on Jul 31, 2010 at 01:20 UTC | |
| |
by josh803316 (Beadle) on Jul 31, 2010 at 05:46 UTC |