php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71581 wrong behaviour when using "." in expression and newline in subject
Submitted: 2016-02-13 08:45 UTC Modified: 2016-02-13 08:59 UTC
From: kurt at kwnet dot at Assigned:
Status: Not a bug Package: PCRE related
PHP Version: Irrelevant OS: linux ubuntu (apache)
Private report: No CVE-ID: None
 [2016-02-13 08:45 UTC] kurt at kwnet dot at
Description:
------------
Search for "," (any character) seems not to include linebreak. => wrong behaviour

Test script:
---------------
//search without newline: correct behaviour
$subject="<tag>Hello World</tag>";
echo "[".preg_match('/<tag>[A-Za-z\\s]*<\\/tag>/',$subject)."]\n"; //[1]
echo "[".preg_match('/<tag>[^<]*<\\/tag>/',$subject)."]\n"; //[1]
echo "[".preg_match('/<tag>.*<\\/tag>/',$subject)."]\n"; //[1]

//search with newline: different behaviour on using "."
$subject="<tag>Hello\nWorld</tag>";
echo "[".preg_match('/<tag>[A-Za-z\\s]*<\\/tag>/',$subject)."]\n"; //[1]
echo "[".preg_match('/<tag>[^<]*<\\/tag>/',$subject)."]\n"; //[1]
echo "[".preg_match('/<tag>.*<\\/tag>/',$subject)."]\n"; //[0] WRONG RESULT



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-02-13 08:46 UTC] kurt at kwnet dot at
Sorry, Description should be correct:
Search for "." (any character)...
 [2016-02-13 08:59 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2016-02-13 08:59 UTC] requinix@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

http://php.net/manual/en/regexp.reference.dot.php

It's the very first sentence on the page.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 15:01:28 2024 UTC