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

Re: [MacPerl] working with strings



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.
:)
-- 
__________________________________________________________________________

Jeff Clites                Online Editor           http://www.MacTech.com/
online@MacTech.com         MacTech Magazine
__________________________________________________________________________

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