in reply to How to get the required names

Anonymous Monk,
It is quite simple with two assumptions: All you need to do is split the name string on non-alpha chars and check each name part:
my @name_part = grep {defined && /[a-zA-Z]/} split /[^a-zA-Z]/, $name;

This of course is probably unrealistic. In that case, you will need to do some actual parsing not just regex matching. If the above suggestion doesn't work, come back with specifics and we will see if we can't be more helpful.

Cheers - L~R

Replies are listed 'Best First'.
Re^2: How to get the required names
by dsheroh (Monsignor) on Dec 25, 2007 at 17:25 UTC
    Assuming the OP just needs a name for lookup (rather than separate firstname and lastname), I would go the opposite direction:
    my $normalized_name = lc $name; $normalized_name =~ tr/a-z//cd; # or =~ s/[^a-z]//g
    All of the examples from the initial post would then become identical maggiesmiths. This would also work for the input MaggieSmith and Bubba-Joe Smith (producing bubbajoesmith) and for names which differ in cApiTaLiZatiOn.

    But, like you said, the specifics are a little sparse, so this solution may also be unsuitable.