Regular Expression for reverse name
Posted: Sat Mar 17, 2012 11:59 am
Hi,
I have been stuck at this problem for sometime now; I have to capture the last first name and title from the following sample string
1.LASTNAME/FIRSTNAME MIDDLENAME1 MIDDLENAME2 MIDDLENAME3 .. MIDDLENAMEn TITLE
FIRSTNAME and MIDDLENAME may not be present
now TITLE can be one of these values MR / MISS / MRS / MSTR / MASTER only; or it could be blank like FIRSTNAME and MIDDLENAME
(?<number>\d+)\.(?<surname>[a-z\s]*)\/((?<firstname>[a-z]+\s{0,1}))*(?<title>mrs|mr|miss|mstr|master){0,1}
In PHP preg_match does not do the trick as the firstname group doesnt capture mutiple values
how can i do this??
I have been stuck at this problem for sometime now; I have to capture the last first name and title from the following sample string
1.LASTNAME/FIRSTNAME MIDDLENAME1 MIDDLENAME2 MIDDLENAME3 .. MIDDLENAMEn TITLE
FIRSTNAME and MIDDLENAME may not be present
now TITLE can be one of these values MR / MISS / MRS / MSTR / MASTER only; or it could be blank like FIRSTNAME and MIDDLENAME
(?<number>\d+)\.(?<surname>[a-z\s]*)\/((?<firstname>[a-z]+\s{0,1}))*(?<title>mrs|mr|miss|mstr|master){0,1}
In PHP preg_match does not do the trick as the firstname group doesnt capture mutiple values
how can i do this??