|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41239 Special chars not handled as alpha numeric
Submitted: 2007-04-30 10:21 UTC Modified: 2007-04-30 11:17 UTC
From: rene dot stabingis at gmail dot com Assigned:
Status: Not a bug Package: *Regular Expressions
PHP Version: 5.2.1 OS: Linux (Debian 3.1)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
32 - 24 = ?
Subscribe to this entry?

 [2007-04-30 10:21 UTC] rene dot stabingis at gmail dot com
This code should delete all non-alphanumeric signs (except spaces).
If you have latin special chars like "?", on the linux machine they are deleted. On a win environment using same php version they are kept as alnum. The deb machine runs with ISO-8859-1 charset.

Reproduce code:
$somePhrase = 'i don\'t know why, but many people know ?ber';
echo preg_replace('/[^[:alnum:][:space:]]/', '', $somePhrase);

Expected result:
i dont know why but many people know ?ber

Actual result:
i dont know why but many people know ber


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-30 10:46 UTC]
You need to use the correct locale, see setlocale() documentation.
 [2007-04-30 11:17 UTC] rene dot stabingis at gmail dot com
I'm sorry but setlocale(LC_ALL, 'de_DE'); has no effect. Same with an explicit set of the german or german/european charset. (btw same behaviour on a freebsd4 machine)
Until now i have only seen problems with this on ubuntu machines running with utf8 standard charset
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Jan 27 00:03:35 2022 UTC