PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Wed Oct 23, 2019 11:45 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Sat Mar 17, 2012 11:59 am 
Offline
Forum Newbie

Joined: Sat Mar 17, 2012 11:38 am
Posts: 2
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??


Top
 Profile  
 
PostPosted: Sat Mar 17, 2012 7:29 pm 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6617
Location: WA, USA


Top
 Profile  
 
PostPosted: Sun Mar 18, 2012 1:08 am 
Offline
Forum Newbie

Joined: Sat Mar 17, 2012 11:38 am
Posts: 2
strangely nope that doesnt work!!


Top
 Profile  
 
PostPosted: Sun Mar 18, 2012 1:59 am 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6617
Location: WA, USA
The only difference between what you posted (after the change) and the working version I have is the end-of-string anchor at the end. Does your actual code have that?


Top
 Profile  
 
PostPosted: Mon Mar 19, 2012 8:36 pm 
Offline
Forum Commoner
User avatar

Joined: Thu Dec 15, 2011 2:40 pm
Posts: 85
Location: Nelson, NZ


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

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 4 guests


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