From:             
Operating system: Linux
PHP version:      5.3.5
Package:          *General Issues
Bug Type:         Feature/Change Request
Bug description:Preg_match_all question/does not return ALL values

Description:
------------
---

>From manual page: http://www.php.net/function.preg-match-all#Description

---



Preg_match_all does not get ALL results.

Test script:
---------------
preg_match_all("/abba/", "abbabba", $resultats);



foreach($resultats[0] as $resultat){

        echo $resultat;

}



Expected result:
----------------
I expect to get 2x abba found instead of 1.  I see 1x abba found.  It is
specifically said that it will be 1 because it start the second search
after the end of the last result found.  Why do it this way?  It is not
that hard to start after the first character of the string found.  So 
There must be some kind of performance reason, which I would like to
understand.





This comes from the fact that I want to get ALL words in a sentence.  But
all words are surrounded by white spaces.  So I have to put the white
spaces in my regex. But because of that I HAVE to double the white spaces
to get ALL words.  Which is something I would like to avoid for
performance.



Please if you have time, send me an email to explain me why is it done that
way.



Thank you in advance.

Actual result:
--------------
I see 1x abba found.



-- 
Edit bug report at http://bugs.php.net/bug.php?id=53951&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=53951&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=53951&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=53951&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=53951&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=53951&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=53951&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=53951&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=53951&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=53951&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=53951&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=53951&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=53951&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=53951&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=53951&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=53951&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=53951&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=53951&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=53951&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=53951&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=53951&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=53951&r=mysqlcfg

Reply via email to