php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31576 mbregex fails to recognise word boundary markers [[:<:]]
Submitted: 2005-01-16 20:39 UTC Modified: 2005-02-21 10:38 UTC
From: mw at lanfear dot com Assigned:
Status: Not a bug Package: mbstring related
PHP Version: * OS: irrelevant
Private report: No CVE-ID: None
 [2005-01-16 20:39 UTC] mw at lanfear dot com
Description:
------------
The mbregex compiler appears to have a bug in it via which it cannot compile the word boundary markers [[:<:]] and [[:>:]] on the Windows version of PHP. (IIS5.1, PHP 5.0.3)

On the Unix version of PHP, these boundaries work fine, with or without the mbstring and mbregex extension enabled, and the Windows versions of PHP will also recognise these markers IFF the mbstring.dll is disabled.

Given the string:

$strr "This is an ip address: 192.168.1.1 ..."

The following:

ereg("[[:<:]][0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[[:>:]]", $strr, $regex);

will generate the following error in windows (IIS5.1, PHP 5.0.3), provided mbstring is enabled:


Warning: mb_ereg() [function.mb-ereg]: mbregex compile err: invalid POSIX bracket type in c:\Inetpub\wwwroot\regex_test.php on line 5
NULL

Reproduce code:
---------------
<?php

$ipaddrs = "192.168.12.22, then followed by 192.168.1.1";

ereg("[[:<:]][0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[[:>:]]", $ipaddrs, $regex);

var_dump($regex);

?>


Expected result:
----------------
array(1) { [0]=>  string(13) "192.168.12.22" }

Actual result:
--------------
Warning: mb_ereg() [function.mb-ereg]: mbregex compile err: invalid POSIX bracket type in c:\Inetpub\wwwroot\regex_test.php on line 5
NULL

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-21 10:38 UTC] moriyoshi@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

[[:<:]] [[:>:]]

These styles of regular expression are not official part 
of POSIX standard.

http://www.opengroup.org/onlinepubs/009695399/basedefs/
xbd_chap09.html

The implementation used in ereg*() is originally 
extended in some way, probably to use with Tcl.

Better use /b and /B instead for more compatibility.

 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Sep 25 03:03:38 2021 UTC