$text = 'I like donkeys'; if ($text =~ /a*((ab)*|b*)/) { print "Success ($1)\n"; }