PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Thu Sep 20, 2018 10:34 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed May 18, 2011 1:37 pm 
Offline
Forum Commoner

Joined: Sun Apr 04, 2010 2:07 pm
Posts: 67
Location: Edinburgh
hi folks!

I have a problem that is getting me crazy! :banghead:

I have
Syntax: [ Download ] [ Hide ]
$string='abcdefghijklmnopqrstuvwxyz';
preg_match('|(([a-z])*)|',$string,$matches);
 


and I want to have in $matches an array such as array('a','b','c','d'...) BUT preg_match keeps only the last match

I DO NOT WANT to use preg_match_all NOR explode, because this is just one small part of my regular expression

Is there a way to do it in php ? I have found the regular expression in http://www.regular-expressions.info/captureall.html
so it can work with other languages, but I don't know if you can do it with PHP!

Thanks!


Top
 Profile  
 
PostPosted: Thu May 19, 2011 5:22 pm 
Offline
DevNet Resident
User avatar

Joined: Wed Apr 01, 2009 1:31 pm
Posts: 1532
lunarnet76 wrote:
I have found the regular expression in http://www.regular-expressions.info/captureall.html
so it can work with other languages

I think you may have misunderstood that article.
regular-expressions.info wrote:
!((abc|123)+)!. When this regex matches !abc123!, capturing group #1 will store abc123, and group #2 will store 123.

If you apply the same concept to your example, the pattern captures the entire string "abcdefghijklmnopqrstuvwxyz" in group #1 and "z" in group #2.

What is the larger pattern you are trying to match?


Top
 Profile  
 
PostPosted: Sat May 21, 2011 6:20 pm 
Offline
Forum Commoner

Joined: Sun Apr 04, 2010 2:07 pm
Posts: 67
Location: Edinburgh
oh gosh, I have read again the article to see what I did not understood, so apparently it simply not possible to get all the letters separated, you can have only the whole pack of letters...

I am doing an Object Query Language so I have something such as SELECT e.*,t.* FROM employee e JOIN telephone t

Then thanks a lot, now I am sure that it is simply not feasible^^ :D

Thank youuuuuu!


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

All times are UTC - 5 hours


Who is online

Users browsing this forum: Google [Bot] 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