php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26134 ereg not working with hex regex
Submitted: 2003-11-05 04:48 UTC Modified: 2003-11-05 11:38 UTC
From: bretschneider at element5 dot com Assigned:
Status: Not a bug Package: Regexps related
PHP Version: 4.3.2 OS: freebsd
Private report: No CVE-ID: None
 [2003-11-05 04:48 UTC] bretschneider at element5 dot com
Description:
------------
ereg does not seam to work with \x values.
it can only matches uppercase !! but \x21-\x7a
includes all upper and lower case characters.

for some reasons i must use ereg and NOT eregi.

preg_match does work! but it does not work with utf-8

Reproduce code:
---------------
$URLS = array(1 => 'FOUND',
              2 => 'notfound');


$pattern = '[\x21-\x7a]+';

foreach ($URLS as $key => $url) {
  print $url;
  if (ereg($pattern, $url)) print " ............ OK\n";
  else print " .............. FAILED\n";
}



Expected result:
----------------
FOUND ............ OK 
notfound .............. OK

Actual result:
--------------
FOUND ............ OK 
notfound .............. FAILED

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-05 11:38 UTC] sniper@php.net
Just change the quotes (') to double quotes (") for the $pattern var and this will work fine.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 06:01:29 2024 UTC