note 101510 added to function.preg-replace

From: Date: Tue, 21 Dec 2010 18:40:45 +0000
Subject: note 101510 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-175115@lists.php.net to get a copy of this message
To extract hiragana, katakana, kanji portion of a Japanese text, explicity set the unicode range AND specify u modifier for the pattern. <? echo "Hiragana -- "; $pattern ='/[^\x{3040}-\x{309F}]+/u'; $s=preg_replace($pattern,"",$str); echo $s."<br />"; echo "Katakana -- "; $pattern ='/[^\x{30A0}-\x{30FF}]+/u'; $s=preg_replace($pattern,"",$str); echo $s."<br />"; echo "Kanji -- "; $pattern ='/[^\x{4E00}-\x{9FBF}]+/u'; $s=preg_replace($pattern,"",$str); echo $s."<br />"; ?> ---- Server IP: 64.71.164.2 Probable Submitter: 98.217.75.228 ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace.php Edit -- https://master.php.net/note/edit/101510 Del: integrated -- https://master.php.net/note/delete/101510/integrated Del: useless -- https://master.php.net/note/delete/101510/useless Del: bad code -- https://master.php.net/note/delete/101510/bad+code Del: spam -- https://master.php.net/note/delete/101510/spam Del: non-english -- https://master.php.net/note/delete/101510/non-english Del: in docs -- https://master.php.net/note/delete/101510/in+docs Del: other reasons-- https://master.php.net/note/delete/101510 Reject -- https://master.php.net/note/reject/101510 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#175115) next »