use strict; use warnings; use v5.24; my $s = "dogcat 42 birdfish"; if ($s =~ /(?<=dog).*\d+(?=fish)/sgxi) { say "Ah! The meaning of life!\n\n"; }