|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12688 preg_match doesn't return newlines in match array
Submitted: 2001-08-10 02:20 UTC Modified: 2001-08-10 11:21 UTC
From: jax at uia dot net Assigned:
Status: Not a bug Package: *Regular Expressions
PHP Version: 4.0.6 OS: FreeBSD 4.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: jax at uia dot net
New email:
PHP Version: OS:


 [2001-08-10 02:20 UTC] jax at uia dot net
This is not a core dump, but rather an output problem with preg_match.  Here is a short script:

$someline = "Here is some line.\n";
if ( preg_match('/Here(.*)$/',$someline,$matches) ) {
  $out = $matches[1];

print "<pre>[$out]</pre>";

$out now contains no newline when this clearly should be included!



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-10 08:49 UTC]
add an "s" to the end of your reg exp.

if (preg_match('/Here(.*)$/s',$someline,$matches)){
this mean "treat everything as one line" and it will parse the
 [2001-08-10 10:56 UTC] jax at uia dot net
Why is this bug bogus?  Isn't it a valid bug when something doesn't Work As Advertised or doesn't Work As Expected?  If these are really perl-compatible regexp functions, this is a real, valid bug.
 [2001-08-10 11:02 UTC]
that is exactly how it works in perl (and I got the answer to
your bug from my Perl book...)
 [2001-08-10 11:21 UTC] jax at uia dot net

Heh, sorry about that.  I verified that they have deprecated $*!  I am too old for this stuff ;)


Eating crow,

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 14 17:01:28 2024 UTC