|  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
28 + 2 = ?
Subscribe to this entry?

 [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-2020 The PHP Group
All rights reserved.
Last updated: Wed Sep 23 09:01:24 2020 UTC