$ echo 'ABC' | perl -ne 'while( /(?=(AB|BC))/g ){ print $1, "\n"; }'
AB
BC

じゃまずいのかな。