[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] working with strings



At 02.46 -0500 1999.01.26, Jeff at MacTech wrote:
>In article <mac-perl.v04020a1db2ce6c6d1b24@[192.168.0.77]>, Chris Nandor
><pudge@pobox.com> wrote:
>
>>  $x = "ATKINSON, TINA                     ";
>>  $x =~ s/^(.+?), (.+?)\s+$//;  # strip off trailing whitespace
>>                                # and capture first, last names
>>  $full = join " ", map {ucfirst(lc($_))} $2, $1;
>>
>...
>>Note that all of these fail where the first or last name is more than one
>>word (like Jim Bob Walsh).  That is a more difficult task, but this gives
>>you a starting point.
>
>Actually, the given pattern should work even with multiple word names, as
>long as there are no commas within either name. (Except that you probably
>want "\s*" at the end, rather than "\s+", just in case the names are long.
>:)

They somewhat work.  They split fine (aside from the \s+ => \s* thing :),
but they do not uppercase the other words.  Of course, sometimes they are
not supposed to be upcased.  Guido von Rossum would not be properly cased
in any possible general code I can think of; you'd have to make his name  a
special case.

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch