|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16512 PREG_SPLIT_DELIM_CAPTURE does not work
Submitted: 2002-04-09 08:59 UTC Modified: 2002-04-09 09:10 UTC
From: bogien at conecto dot pl Assigned:
Status: Closed Package: PCRE related
PHP Version: 4.1.2 OS: Win32, Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
22 + 12 = ?
Subscribe to this entry?

 [2002-04-09 08:59 UTC] bogien at conecto dot pl
PREG_SPLIT_DELIM_CAPTURE does not work - preg_split() simply omits the delimiters disregarding the flag.

The following line:

print_r(preg_split('/a/', 'mama', -1, PREG_SPLIT_DELIM_CAPTURE));


    [0] => m
    [1] => m
    [2] => 

...just like without the last argument - while it should return:

    [0] => m
    [1] => a
    [2] => m
    [3] => a
    [4] => 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-09 09:10 UTC]
Read the manual:


If this flag is set, parenthesized expression in the delimiter pattern will be captured and returned as well. This flag was added for 4.0.5.

So your pattern should look like:

and presto, it works.
 [2002-09-24 04:54 UTC] ed at avi dot ru
It will be a nice idea to put this example to documentation; I was already going to send a bug report about PREG_SPLIT_DELIM_CAPTURE when I found this article.
 [2011-05-05 14:18 UTC] admin2011 at luebker dot org
very useful information, please add to documentation or highlight the phrase "parenthesized expression". Thanks.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Sep 21 17:01:23 2020 UTC