php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20631 PCRE_CASELESS doesn't work
Submitted: 2002-11-25 16:50 UTC Modified: 2002-12-06 11:56 UTC
From: matt at zevi dot net Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 4.3.0RC1 OS: Linux 2.4.19
Private report: No CVE-ID: None
 [2002-11-25 16:50 UTC] matt at zevi dot net
preg_replace():

This regex was case insensitive in 4.2.3, but is case sensitive in 4.3.0RC1: '/\(name\)(?i)/'

Was not able to test further because I installed it on a production box, and had to revert to 4.2.3...

I had the search and replace values in arrays which I then passed to preg_replace().  This may have some effect on it.  I didn't test just passing a string.

Matt

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-27 00:22 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Unless you specify the 'i' flag your regular expression will NOT be case-insensetive. For example the regex you've shown should appear like this:
'/\(name\)(?i)/i'

If you want it not to be case sensetive.
 [2002-11-27 19:25 UTC] matt at zevi dot net
I respectfully disagree... :)

My code definitely was case-insensitive in 4.2.2 and 4.2.3, and when I installed 4.3.0RC1 it was case-sensitive.  There's definitely something fishy going on.

The following page details the setting of internal options by using the (?) construct.
http://www.php.net/manual/en/pcre.pattern.syntax.php#regexp.reference.internal-options

According to this page, what I'm doing is correct.

I really don't mind changing my function to use perhaps eregi_replace or something else, but I really think this could be an issue for users who currently use preg_* functions with case-insensitivity (I'm sure there would be a few of them...)

Matt
 [2002-11-27 19:26 UTC] matt at zevi dot net
Forgot to change back to open...
 [2002-11-28 08:53 UTC] iliaa@php.net
This is indeed a bug, you are correct. The bug is due to us bundling a pcre library which appears to have a bug, which causes the behaviour you describe.
As an intermittent solution, you can compile your own pcre library and compile php with --with-pcre-regex=/path/to/pcre/lib
 [2002-12-06 11:56 UTC] iliaa@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Apparently the meaning of (?i) paterns had changed intentionally in PCRE library. So, this is not a bug afterall.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Dec 06 18:03:34 2021 UTC