aboutsummaryrefslogtreecommitdiff
path: root/challenge-273/e-choroba/perl/ch-2.pl
diff options
context:
space:
mode:
author冯昶 <fengchang@novel-supertv.com>2024-06-19 10:19:37 +0800
committer冯昶 <fengchang@novel-supertv.com>2024-06-19 10:19:37 +0800
commit8fea6debb2f1582d761fcb3842dc1f8d9bc683ea (patch)
treeaa8434550ab5ac39df8b5fc66084bbdd6c7ecbf1 /challenge-273/e-choroba/perl/ch-2.pl
parent2a6cdeb8e1b429bdb337b3e261f83bdd0a5b80d9 (diff)
parentffc47a8850ee877978e371d11a01a028862a3f9d (diff)
downloadperlweeklychallenge-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-xchallenge-273/e-choroba/perl/ch-2.pl22
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';