note 81124 rejected from function.mb-eregi-replace by nlopess
| From: | nlopess@php.net | Date: | Thu, 14 Feb 2008 20:16:43 +0000 |
| Subject: | note 81124 rejected from function.mb-eregi-replace by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-136160@lists.php.net to get a copy of this message | ||
Note Submitter: sangwal at mailinfinity dot com
----
The function mb_eregi_replace does not seem to understand that Polish letters Å and Å are same
letter except for the difference of case. Similar is the case with Å, Ä, Ã, Ä etc.
<?php
function clean_text($str, $pattern = "[^ a-zÄ
ÄÅÅóżź]")
{
// there is some problem with Å. don't know what
mb_regex_encoding('utf-8');
mb_internal_encoding("UTF-8");
return mb_eregi_replace($pattern, "", $str);
}
$str = "SUÅIÅ sÄ
ÅgwÄÅ this SUÅÃŻŹÄIL contains also a-z Ä
Ä Å Å Ã³ ż ź + 012334338 / + \" {} sun3il";
print clean_text($str);
?>
Its output is:(html is added for clarity sake that utf-8 was in effect)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Title</title>
</head>
SUI sÄ
ÅgwÅ this SUIL contains also az Ä
Ä Å Å Ã³ ż ź sunil
-- end of output --
As is obious from the code, I wanted to retain only Polish letters in the string and get rid of all
others whatever. Does anybody know if it can be done with one regex-replace? Thanks.
PS: Sorry I previously added this note at a wrong entry :(