php.net |  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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
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!

--Liam

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-10 08:49 UTC] alindeman@php.net
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
newline.
 [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] alindeman@php.net
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
Ahhhh,

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

Thanks!

Eating crow,

--Liam
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 07:01:31 2024 UTC