note 81123 added to function.mb-regex-encoding
| From: | sangwal at mailinfinity dot com | Date: | Thu, 14 Feb 2008 19:36:08 +0000 |
| Subject: | note 81123 added to function.mb-regex-encoding | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-136155@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 82.177.164.100
Probable Submitter: 149.156.67.246
----
Manual Page -- http://www.php.net/manual/en/function.mb-regex-encoding.php
Edit -- https://master.php.net/note/edit/81123
Del: integrated -- https://master.php.net/note/delete/81123/integrated
Del: useless -- https://master.php.net/note/delete/81123/useless
Del: bad code -- https://master.php.net/note/delete/81123/bad+code
Del: spam -- https://master.php.net/note/delete/81123/spam
Del: non-english -- https://master.php.net/note/delete/81123/non-english
Del: in docs -- https://master.php.net/note/delete/81123/in+docs
Del: other reasons-- https://master.php.net/note/delete/81123
Reject -- https://master.php.net/note/reject/81123
Search -- https://master.php.net/manage/user-notes.php