Bod has asked for the wisdom of the Perl Monks concerning the following question:
I need to split a name string into first and last names. The name comes from user input on a web form and the only validation is that there is data submitted. It could be just one character, it could have multiple spaces, training spaces, etc.
This is the regexp I have for doing this task.
my ($fname, undef, $sname) = $xmas->{'fromName'} =~ /(\w+)( +|\Z)(\w*) +/;
It works for my simple testing but is there a "better" way to do it? However you define better!
The obvious problem is that it fails with extended characters such as Zoë.
Back to
Seekers of Perl Wisdom