"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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.