php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66708 preg_match reports missing right-perand incorrectly
Submitted: 2014-02-13 16:29 UTC Modified: 2014-02-13 19:14 UTC
From: jbeecher at oneendlessloop dot com Assigned:
Status: Not a bug Package: Regexps related
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
 [2014-02-13 16:29 UTC] jbeecher at oneendlessloop dot com
Description:
------------
Valid regexp: /[a-z0-9]{1,25}\s+([0-9]{3,12})\s+[.]*(\-\c)/i



Test script:
---------------
Example data (to grep against):

blinky  5321     1  0 Feb07 ?        00:03:41 php ./di-sup.php -c 1 -i /ftpacct/max/pub/MAX -p /ftpacct/max/pub/MAX -n mixlplick -l /home/blinky/M006615/custlogs/MAX -e reports@maxic-reports.com -x rubber1333!



Expected result:
----------------
preg_match() should return an array of matched values.

Actual result:
--------------
preg_match() returned false (not zero, but boolean false) i.e. there was an error.
The error message was, "preg_match(): Compilation failed: missing ) at offset 43"

Which is incorrect.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-02-13 17:27 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2014-02-13 17:27 UTC] requinix@php.net
\c is supposed to be \cX, where X is a character. Together they form the escape sequence for a control character. You've given it \c). You'd need another ) after that - except I don't think you mean to use \c) in the first place.
 [2014-02-13 18:33 UTC] jbeecher at oneendlessloop dot com
Okay.  Per the PCRE docs I'm aware of the backslash character is used to escape the next character to its literal form.  I just wanted to make sure it saw it as a 'c'.  I have never seen PCRE consider backslash-c as a control character...  If that's so, it's undocumented.
 [2014-02-13 18:37 UTC] jbeecher at oneendlessloop dot com
To add... normally if I'm going to specify any control character, I would use \x{5B}  where '5B' is whatever the hex code is I wish to check for.  Please confirm that '\c' is also for control characters, reference a source-document, and provide an example.
 [2014-02-13 18:58 UTC] jbeecher at oneendlessloop dot com
*thank you*.... is this for all versions of PHP, or is this a 5.5 or later sort of thing?
 [2014-02-13 19:14 UTC] requinix@php.net
Looks to have been in place since at least 4.3.0.
http://3v4l.org/S6sgk
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC