php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36900 \s incorrectly matches new-line in multi-line mode
Submitted: 2006-03-28 23:33 UTC Modified: 2006-03-28 23:41 UTC
From: andrew dot minerd at sellingsource dot com Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.1.2 OS: Gentoo Linux
Private report: No CVE-ID: None
 [2006-03-28 23:33 UTC] andrew dot minerd at sellingsource dot com
Description:
------------
When using multiline mode in a regular expression, \s incorrectly matches a new-line character.

Reproduce code:
---------------
$info = <<<INFO
	Sender:
	Pages: 1
INFO;

preg_match_all('/^\s*([^:]+?):\s*(.*)$/m', $info, $matches, PREG_PATTERN_ORDER);

// combine into an array of key=>value pairs
$info = array_combine(array_map('strtolower', $matches[1]), $matches[2]);

var_dump($info);

Expected result:
----------------
array(2) {
  ["sender"]=>
  string(0) ""
  ["pages"]=>
  string(1) "1"
}

Actual result:
--------------
array(1) {
  ["sender"]=>
  string(8) "Pages: 1"
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-28 23:41 UTC] tony2001@php.net
PHP doesn't parse regular expressions, it just wraps PCRELib.
And if PCRELib behaves wrong - there is nothing we can do about it.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 07:01:32 2024 UTC