|  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: bretschneider at element5 dot com
New email:
PHP Version: OS:


 [2003-11-05 04:48 UTC] bretschneider at element5 dot com
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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-05 11:38 UTC]
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: Sun Feb 25 11:01:27 2024 UTC