while ( ) { chomp; print "$_: ", /^a.*b$/ && !/.ab./ ? "yes" : "no", "\n"; } __DATA__ a000000000b a0a0000b00b a0000ab000b ab00000000b a000ab #### a000000000b: yes a0a0000b00b: yes a0000ab000b: no ab00000000b: yes a000ab: yes