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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: runesk at radar dot no
New email:
PHP Version: OS:

 

 [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: Thu Oct 08 03:00:02 2026 UTC