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

From: Date: Fri, 10 Jul 2015 01:47:08 +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-194271@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:         keithm at aoeex dot com
 Reported by:        chrisdmiddleton at gmail dot com
 Summary:            PCRE_DOLLAR_ENDONLY fails on newlines when used with
                     pipe operator
 Status:             Open
 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:

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.


Previous Comments:
------------------------------------------------------------------------
[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


Thread (4 messages)

« previous php.bugs (#194271) next »