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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: andrew dot minerd at sellingsource dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 11:01:32 2025 UTC