Bug #76185 [Fbk->NoF]: preg_split Removes Empty lines when flag is not set
Edit report at https://bugs.php.net/bug.php?id=76185&edit=1
ID: 76185
Updated by: php-bugs@lists.php.net
Reported by: will at bisbeefamily dot com
Summary: preg_split Removes Empty lines when flag is not set
-Status: Feedback
+Status: No Feedback
Type: Bug
Package: *General Issues
Operating System: Windows 10/Apache
PHP Version: 5.6, 7.1 & 7.2.3
Private report: N
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2018-04-06 04:24:54] requinix@php.net
https://3v4l.org/jKupd
The output looks correct to me. What are you expecting to see?
------------------------------------------------------------------------
[2018-04-06 04:15:45] will at bisbeefamily dot com
<?php
$buffer = "
%target:admin_media.php%
%location:%
$showmedia_url = getURL( 'showmedia', 1 );
%end:%
%insert:after%
// ****** following line added by Showfolio mod ******
$showfolio_url = getURL( 'showfolio', 1 );
%end:%
";
// STANDARDIZE LINE ENDINGS
$buffer = preg_replace( "#(?:\r\n|\r\r\n|[\r\n])#", "\r\n", $buffer );
// CREATE WORKING TABLE
$parts = preg_split( "#^\s*%(\w+):#m", $buffer, NULL,
PREG_SPLIT_OFFSET_CAPTURE|PREG_SPLIT_DELIM_CAPTURE );
print_r( $parts );
?>
------------------------------------------------------------------------
[2018-04-05 00:10:52] requinix@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
But did you know that \s will match newline characters?
------------------------------------------------------------------------
[2018-04-04 23:58:05] will at bisbeefamily dot com
Description:
------------
$parts = preg_split( "#^\s*%(\w+):#sm", $buffer, null,
PREG_SPLIT_OFFSET_CAPTURE|PREG_SPLIT_DELIM_CAPTURE );
Removes empty lines between the split targets even though the PREG_SPLIT_NO_EMPTY flag is not set.
Test script:
---------------
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76185&edit=1
Thread (5 messages)