while (/A(BC)?D/g) { push @matches, $1 if $1; }