>perl -wMstrict -le "my $rx = qr{^[a-zA-Z]+(['.]?\s*[a-zA-Z]+)*$}xms; print '--- output --'; for (@ARGV) { print m{$rx} ? ' ' : 'NO', ' match: ', $_; } " "all of the following should match" "FooBar Tech" "St.John's high school." "A. B. C. school." "Institute of management." "oxford university." "A.B.C college." "Ragu ram's college of technology." "none of the following should match" "A..B.C college." "St.John''s high school." "St.John'.'s high school." --- output -- match: all of the following should match match: FooBar Tech NO match: St.John's high school. NO match: A. B. C. school. NO match: Institute of management. NO match: oxford university. NO match: A.B.C college. NO match: Ragu ram's college of technology. match: none of the following should match NO match: A..B.C college. NO match: St.John''s high school. NO match: St.John'.'s high school.