#!/usr/local/bin/perl use strict; use warnings; #f = first, s = second. my $f='ABCAAAABBBCCCCCAAABBBCCC'; my $s='ASRGRTGRT89579843rrrrrr'; print $f=~/(?=^[ABC]+$)/? "Matches [ABC] Combinations\n": "No pattern found!\n"; print $s=~/(?=^[ABC]+$)/? "Matches [ABC] Combinations\n": "No pattern found!\n"; #### #OUTPUT: Matches [ABC] Combinations No pattern found ####