problem with mbstring (search)functions

From: Date: Thu, 23 Jan 2003 09:42:02 +0000
Subject: problem with mbstring (search)functions
Groups: php.i18n 
Request: Send a blank email to php-i18n+get-423@lists.php.net to get a copy of this message
When trying to do a search in a mbstring, I sometimes(!) get the following error: " Warning: mb_ereg_search()[function.mb-ereg-search]:mbregex compile err: premature end of regular expression in c:\myfile.php on line 12. " It's only the case for some strings. Why is this? I assume it must something related to the word itself interacting with the mbfunctions I'm using PHP 4.3.0. I added an example below where it fails... I noticed that if i add a space in the $word string it works, but I'm sure there's nothing wrong with $word. Thanks a lot!!!!! Simon Maybe this little file helps to see what i'm talking about: Copy & paste away <html> <head> <meta http-equiv="Content-Type" content="Text/Html; Charset=UTF-8"> <title>coding-problem</title> </head> <body> <?php $examplesnt="わたしわ"; $word="愛犬"; //**************************FUNCTIONS******************************************* function find_word($word,$sentence) { mb_ereg_search_init ($sentence); $result=mb_ereg_search($word); if($result==1){ echo "$sentence contains $word<br>"; } return $result; } //************************MAIN************************************************** /* Set internal character encoding to UTF-8 */ mb_internal_encoding("UTF-8"); /* Display current internal character encoding */ echo mb_internal_encoding()."<br>"; echo $examplesnt." is the example sentence<br>"; echo $word." is the word we're looking for in the sentence<br>";// i know the word is not in it, but that doesn't matter find_word($word,$examplesnt); ?> </body> </html>

« previous php.i18n (#423) next »