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.
|