PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Feb 20, 2017 1:14 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sun Apr 19, 2015 6:05 pm 
Offline
Forum Newbie

Joined: Sun Apr 19, 2015 5:55 pm
Posts: 1
I am dealing with input that is a string containing a full name, many times over.
I am using regex to split the full name in to...

[list=]
[*]First name: ^\S*
[*]Middle name: \s+(.*\b)\s+
[*]Last name: \S+$
[/list]

But full names come in a variety of formats. One tricky pest is a full name with brackets, in the form "Ceri Tinine (née Jones)". I don't need " (née Jones)". And this throws off the middle and last name detection above. I only want to split "Ceri Tinine" in to first, middle and last names.

So, I need to reconstruct the regexs above so that each match is made on a full-name string that first looks to stop at the space preceding "(" or, else, the end of the full-name string.

How do I effectively combine these?

I am only just learning this stuff. No PHP needed - I only want to do this in regex if possible.

Many thanks.


Top
 Profile  
 
PostPosted: Mon Apr 20, 2015 5:02 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13382
Location: New York, NY, US
Please post the regexp that you have developed.

_________________
(#10850)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group