Bug #70037 [Com]: PCRE_DOLLAR_ENDONLY fails on newlines when used with pipe operator

From: Date: Fri, 10 Jul 2015 04:23:35 +0000
Subject: Bug #70037 [Com]: PCRE_DOLLAR_ENDONLY fails on newlines when used with pipe operator
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194274@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70037&edit=1 ID: 70037 Comment by: chrisdmiddleton at gmail dot com Reported by: chrisdmiddleton at gmail dot com Summary: PCRE_DOLLAR_ENDONLY fails on newlines when used with pipe operator Status: Not a bug Type: Bug Package: PCRE related Operating System: Mac OS X 10.9.4 PHP Version: 5.6.10 Block user comment: N Private report: N New Comment: Whoops - you're complete right. Sorry for the false alarm. I've been bitten by regex operator precedence before - hopefully this will be the last time. Thanks for pointing out my error. Previous Comments: ------------------------------------------------------------------------ [2015-07-10 03:46:57] requinix@php.net Yup. ------------------------------------------------------------------------ [2015-07-10 01:47:08] keithm at aoeex dot com The given test case is performing as expected. It matches on the ^\n branch of the regular expression. /^\n|\n$/D means: Match start-of-input followed by a new-line OR a new-line followed by end-of-input. ------------------------------------------------------------------------ [2015-07-09 23:29:49] chrisdmiddleton at gmail dot com Description: ------------ When trying to match newlines with the PCRE_DOLLAR_ENDONLY modifier in conjunction with the "|" operator, it matches more than it should. My original test case was using a regex of '/^\n|\r\n|\r$/D' against a string containing other characters. I've simplified the test below. Test script: --------------- echo preg_match('/^\n|\n$/D', "\nasdf", $matches); Expected result: ---------------- 0 Actual result: -------------- 1 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70037&edit=1

« previous php.bugs (#194274) next »