I am looking for a regex which would extract the intials from a string i.e.
str = "Doe, John L.L.M"; $str =~ /(^(\w)).*?((\s)(\w)).*?((\s)(\w))/; $initial = $1.$2.$3; print "$initial"; The above code is not serving my purpose. String constants: There would be always 3 words (obvioulsy with 2 spaces in between) in the string however string may contain periods (.) and (,) in it. I am looking to extract. 1. First Character of the string. 2. Next two Characters after space in the String. Doe, John L.L.M should be "DJL" Simth, G. M.D. should be "SGM" Any help, please? Thanks, Sara.