use strict; use warnings; while( ) { chomp; printf q{%16s : }, $_; print m{(?x) (?: (?<=\A) | (?<=\D) ) (\d[A-Z]) (?![A-Z])} ? qq{Found $1\n} : qq{No match\n}; } __DATA__ 2L bar.2L bar.ber.bir. 2L pob33J.slob bar.ber.bir.2L foo.3Hbar jar.8GH 6Ytootle par.4T.spootle