electric-fire 1 Posted June 12, 2014 Report Share Posted June 12, 2014 Hi, I was learning the code on creating a search engine, that accompanies this book from here: http://www.peachpit.com/articles/article.aspx?p=1802754&seqNum=4 and encountered an issue in the se_index.php file. Everything worked fine until I tryed cyrillic characters, the preg_match_all('/\b\w+\b/', $content, $output) function didn't allow them to get through: After researching the net I fount the solution adding the u caracter for unicode like this: preg_match_all('/\b\w+\b/u', $content, $output); and it worked on the localhost with LAMPP. Recently I tried to index a website on a shared hosting that runs PHP-5.2.17, and the same method that worked on the localhost, didn't with cyrillic there. I also tryed preg_match_all('/\b\[a-zA-Z\p{Cyrillic}0-9]+\b/u', $content, $output); and other combinations of regular expressions with the \p{Cyrillic} but nothing worked so far. If anybody has knowlege how to solve this issue, please give me a note, thanks. Quote Link to post Share on other sites
HartleySan 826 Posted June 12, 2014 Report Share Posted June 12, 2014 This may be of use: http://www.php.net//manual/en/regexp.reference.unicode.php This may also help: http://stackoverflow.com/questions/5767056/php-regex-for-multiple-unicode-characters And finally, this may help (especially the link in the top-rated answer): http://stackoverflow.com/questions/6407983/utf-8-in-php-regular-expressions 1 Quote Link to post Share on other sites
electric-fire 1 Posted June 13, 2014 Author Report Share Posted June 13, 2014 Thanks for the help! Quote Link to post Share on other sites
HartleySan 826 Posted June 13, 2014 Report Share Posted June 13, 2014 Sure. Did you solve your problem, and if so, how? Thanks. Quote Link to post Share on other sites
electric-fire 1 Posted August 10, 2014 Author Report Share Posted August 10, 2014 Sorry for the long delay, I haven't had an opportunity to try it on a live web hosting with the search engine yet, but I just managed to make a related task: Leaving the Cyrillic and Latin characters, numbers, dots, dashes, and spaces intact in a string, while replacing any other characters with an underscore. The 1st link:http://php.net//manual/en/regexp.reference.unicode.php was of help! Here is the code: $modified_filename = preg_replace("/[^\\s\\p{L}0-9 .-]/u", "_", $filename); Thanks again. 1 Quote Link to post Share on other sites
HartleySan 826 Posted August 11, 2014 Report Share Posted August 11, 2014 No problem. Glad you reached what seems like a resolution. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.