On 5/11/07, Chas Owens <[EMAIL PROTECTED]> wrote:
On 5/11/07, Tony Heal <[EMAIL PROTECTED]> wrote:
> I have a list of names that I need to break up and reassemble.
>
> The list consists of the first name and last name combined as a single word
in wiki format. i.e.JoeBlow
>
> I need to break this up and recreate the list as
>
> | FirstName | LastName | Email | WikiName |
>
> i.e.
>
> | Joe | Blow | [EMAIL PROTECTED] | JoeBlow |
>
> I can do all of this except break the original word apart.
>
> Tony
Assuming that JoeMcCarthey should be Joe McCarthy, I would do this
my ($first, $Last) = $wikiname =~ /([A-Z]\w*?)([A-Z]\w*)/;
But what about JoAnnConnors? JKRowling? HunterSThompson? Parsing
wikinames effectively is a tricky business. Unless the rules governing
name creation were very strict--only allowing a certain number of
capitals--or only allowing capitals in certain places, which was the
original intention, but most wikis don't actually force users to take
names like JrrTolkien--you'll probably want to pass anything with
three or more caps to a human for processing, or at least to a more
sophisticated routine:
my ($fisrt, $last)
my @name = $wikiname = /([A-Z][a-z]*)/g;
if (@name <= 2) {
($first, $last) = @name;
else {
figure_it_out(@name);
}
figure_it_out could either just email the name to person for
clarification, or apply a little logic. Maybe match list elements
against common name parts:
if (@name[-2] =~ /^Ma?c/) {
$first = join ' ', @name[0..-3];
$last = @name[-2] . @name[-1];
etc.
HTH,
-- jay
--------------------------------------------------
This email and attachment(s): [ ] blogable; [ x ] ask first; [ ]
private and confidential
daggerquill [at] gmail [dot] com
http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org
values of β will give rise to dom!