in reply to Re: Re: Handling caps for surnames with capitals in the middle (was: Irish Surnames)
in thread Handling caps for surnames with capitals in the middle (was: Irish Surnames)
If it were my surname you were mauling, I'd be more than a bit annoyed. I get enough of my surname's Anglicised (actually Brazilinated, but it's close enough) form being auto-"corrected" into the original Russian. I am actually capable of spelling it correctly, and I do just that.
That said, you could
(assumes the surname starts off lower-cased).$surname =~ s/^((?:Mc|Mac|De|Da|Du)?)(.*)$/\u\1\u\2/i;
Other problems: not smart enough. E.g. <samp>'mack'</samp> becomes <samp>'MacK'</samp>, which is wrong; you might want .{3,} instead of .* in the regexp.
But I really don't think you should be doing this...
|
|---|