Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
"Thanks Ken for the helpful code ..."

You're welcome.

"With regards changing the form, that won't be happening as explained in Re^2: Split first and last names"

That's new information (only posted an hour or so ago) but does add some clarity.

"... full name (... envelope) ... firstname ... salutation."

Perhaps something along these lines:

#!/usr/bin/env perl use strict; use warnings; use utf8; use open OUT => qw{:encoding(UTF-8) :std}; my @names = ("Zoë", "Zoë Åcçéñt-Smythe"); my $re = qr{(?x: ^ ( ( [\p{Alpha}'_-]+ ) [\s\p{Alpha}'_-]* ) $ )}; for my $name (@names) { my ($full, $first) = $name =~ $re; print "Name: $name\n"; print "First: $first\n"; print "Full: $full\n"; }

Output:

Name: Zoë First: Zoë Full: Zoë Name: Zoë Åcçéñt-Smythe First: Zoë Full: Zoë Åcçéñt-Smythe

Note that I allowed three punctuation characters ('_-); alter as necessary. I know, from earlier posts, that you're across SQL injection issues. Be aware, that between reading data from the web and supplying it to SQL, there may be other code injection issues. Without knowing anything more about your code, that's something you'll need to assess for yourself: I didn't include any validation; but you should.

"As for the database storage..."

I looks like most of that would be covered by "If we need extra information ... we ask for it ...". The majority wouldn't be covered by user input anyway (e.g. nickname, preferred names). Again, something for you to determine using the same principles as above (i.e. limited regex capture, code injection & validation).

— Ken


In reply to Re^3: Split first and last names by kcott
in thread Split first and last names by Bod

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-24 09:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found