in reply to regex: seperating parts of non-formatted names

A good approach to programming problems in general is "breaking the problem into pieces". This is true for regular expressions in general. So I'd start writing the main regexp like that:

$name = qr{($title)?\W+($first)?\W+($middle)?\W+($last)};

And now you define each of the variables on their own, of course above this declaration.

#the title shall be extensible, ok my @titles = qw/LTC COL DR MS MR MISS/; my $title = join('|',@titles); $title = qr[(?:$title)\.]i; #case-insensitive match # first name: no restrictions? my $first = qr[\w+]; # middle initial my $middle = qr{(?:\s*[A-Z]\.)+}; # last name: no restrictions? my $last = qr[\w+];

Any more details should be nop big problem. HTH to <cite>enlighten of the powers of perl</cite> :)

update: untested, there may be more mistakes...

--
http://fruiture.de