diff options
Diffstat (limited to 'challenge-273/e-choroba/perl/ch-2.pl')
| -rwxr-xr-x | challenge-273/e-choroba/perl/ch-2.pl | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/challenge-273/e-choroba/perl/ch-2.pl b/challenge-273/e-choroba/perl/ch-2.pl new file mode 100755 index 0000000000..3ebdf460d3 --- /dev/null +++ b/challenge-273/e-choroba/perl/ch-2.pl @@ -0,0 +1,22 @@ +#!/usr/bin/perl +use warnings; +use strict; +use experimental qw( signatures ); + +sub b_after_a($str) { + $str =~ /^ # Start of the string. + [^b]* # Anything up to the first b. + b # The first b. + (?! # Not folllowed by... + .* # ... anything... + a # ... and a. + ) + /x +} + +use Test::More tests => 4; + +ok b_after_a('aabb'), 'Example 1'; +ok ! b_after_a('abab'), 'Example 2'; +ok ! b_after_a('aaa'), 'Example 3'; +ok b_after_a('bbb'), 'Example 4'; |
