php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1594 preg_* doesn't use locale
Submitted: 1999-06-24 06:50 UTC Modified: 1999-07-20 17:09 UTC
From: runesk at radar dot no Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.9 OS: RedHat Linux 6.0 kernel 2.2.5
Private report: No CVE-ID: None
 [1999-06-24 06:50 UTC] runesk at radar dot no
It seems like preg_* doesn't use the locale setting.
<?php
  setlocale("LC_ALL", "no_NO");
  $str = "???";
  if(preg_match("/\w{3}/", $str, $foo)) {
    echo "matched \\w{3}\n";
  }
  if(preg_match("/???/", $str, $foo)) {
    echo "matched ???\n";
  }
?>

_Should_ match both tests, but only matches the last one.

#!/usr/bin/perl
use locale; 
$_ = "???"; 
if(/\w{3}/) { 
  print "matched \\w{3}\n"; 
} 
if(/???/) { 
  print "matched ???\n"; 
}

matches both tests.

Rune N. Skillingstad

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-06-24 11:00 UTC] andrey at cvs dot php dot net
This is planned for a future upgrade.
 [1999-07-20 17:09 UTC] andrey at cvs dot php dot net
Locale support has been added for 3.0.12 and for PHP 4.0.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 22:00:01 2026 UTC