php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44543 preg_split: patterns with assertions
Submitted: 2008-03-26 22:33 UTC Modified: 2008-03-26 22:44 UTC
From: unkind at regex dot su Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.2.5 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: unkind at regex dot su
New email:
PHP Version: OS:

 

 [2008-03-26 22:33 UTC] unkind at regex dot su
Description:
------------
I want to split string like this: "cell:cell:cell with '\:':cell" by pattern "/(?!\\):/"

Reproduce code:
---------------
<?php
$s = "cell:cell:cell with '\\:':cell";
$s = preg_split('/(?!\\\\):/', $s);

print_r( $s );
?>

Expected result:
----------------
Array
(
    [0] => cell
    [1] => cell
    [2] => cell with ':'
    [3] => cell
)

Actual result:
--------------
Array
(
    [0] => cell
    [1] => cell
    [2] => cell with '\
    [3] => '
    [4] => cell
)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-26 22:44 UTC] felipe@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The your regexp no make senses, and a regexp doesn't will remove the escape on matching.

http://www.pcre.org/man.txt
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 09:01:34 2025 UTC