Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: Newbie parsing problem

by vaticide (Scribe)
on Jan 25, 2007 at 16:47 UTC ( [id://596544]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Newbie parsing problem
in thread Newbie parsing problem

Thanks, I noticed that, too, when I changed it to plug into the test case. Fairly embarrasing considering I do name parsing such as this regularly at work!

Replies are listed 'Best First'.
Re^4: Newbie parsing problem
by rtremaine (Acolyte) on Jan 25, 2007 at 21:55 UTC
    great solutions, I have noticed that:
    my ($last, $first, $middle) = ($name =~ /(\w+)\W*?(\w+)\W*(\w)?/);
    doesn't handle lastnames with hypens in them, any ideas? thanks again!
      \w only matches letters, digits and underscores. since the hyphen is a non-word (\W), that regex interprets it as a separator, so that the second part of the last name is considered the first name.
      the following code supports hyphenated first and last names:
      my ($last, $first, $middle) = ($name =~ /([\w-]+)\W*?([\w-]+)\W*(\w)?/);

      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      *women.pm
        ahhh, I see! thanks again for all your help!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://596544]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2024-04-24 23:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found