diff options
| author | 冯昶 <fengchang@novel-supertv.com> | 2024-06-19 10:19:37 +0800 |
|---|---|---|
| committer | 冯昶 <fengchang@novel-supertv.com> | 2024-06-19 10:19:37 +0800 |
| commit | 8fea6debb2f1582d761fcb3842dc1f8d9bc683ea (patch) | |
| tree | aa8434550ab5ac39df8b5fc66084bbdd6c7ecbf1 /challenge-273/e-choroba/perl/ch-2.pl | |
| parent | 2a6cdeb8e1b429bdb337b3e261f83bdd0a5b80d9 (diff) | |
| parent | ffc47a8850ee877978e371d11a01a028862a3f9d (diff) | |
| download | perlweeklychallenge-club-8fea6debb2f1582d761fcb3842dc1f8d9bc683ea.tar.gz perlweeklychallenge-club-8fea6debb2f1582d761fcb3842dc1f8d9bc683ea.tar.bz2 perlweeklychallenge-club-8fea6debb2f1582d761fcb3842dc1f8d9bc683ea.zip | |
Merge remote-tracking branch 'upstream/master'
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'; |
