note 81123 added to function.mb-regex-encoding

From: 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

« previous php.notes (#136155) next »