Bug #76185 [Opn->Fbk]: preg_split Removes Empty lines when flag is not set
| From: | requinix@php.net | Date: | Fri, 06 Apr 2018 04:24:55 +0000 |
| Subject: | Bug #76185 [Opn->Fbk]: preg_split Removes Empty lines when flag is not set | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-214629@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76185&edit=1
ID: 76185
Updated by: requinix@php.net
Reported by: will at bisbeefamily dot com
Summary: preg_split Removes Empty lines when flag is not set
-Status: Open
+Status: Feedback
Type: Bug
Package: *General Issues
Operating System: Windows 10/Apache
PHP Version: 5.6, 7.1 & 7.2.3
Block user comment: N
Private report: N
New Comment:
https://3v4l.org/jKupd
The output looks correct to me. What are you expecting to see?
Previous Comments:
------------------------------------------------------------------------
[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