in reply to Re^2: simpler regex
in thread simpler regex
Of course, given that sort of regex, I guess it doesn't matter whether you join the parts before or after the substitution. (It's using negative look-behind and negative look-ahead to check that a single upper-case letter is neither preceded nor following by a non-whitespace character, and in that case, put a period after the letter.)sub fullname { my @parts = @_; for ( @parts ) { s/(?<!\S)([A-Z])(?!\S)/$1./g; } return join " ", @parts; }
|
|---|