0

Possible Duplicate:
php preg_replace with Unicode chars

I have tried to solve this myself but failed.

I need to "clean" my string using PHP preg_replace so every character except a-z, A-Z, 0-9, space (' ') and latin letters "ČčĆćĐ𩹮ž" are removed.

I have learned how to solve first part of my problem: $cleanstring = preg_replace('[^a-zA-Z0-9 ]', '', $originalstring);

But I'm not successful in including other latin letters in my pattern. I do not need all latin characters, just those listed above.

Edit: When my $originalstring is "Đak", my $cleanstring is "272ak"! How can I fix this?

Can anybody help? Thank you in advance!

milosh

Community
  • 1
  • 1
milosh
  • 200
  • 3
  • 11
  • 1
    Instead of stripping the characters, you could also just [convert them to the ASCII letter without diacritics](http://stackoverflow.com/questions/4881085/php-is-there-a-way-to-transfer-latin-letters-to-english-letters?rq=1). – Lèse majesté Sep 03 '12 at 15:36
  • I do not want to allow all latin chars with \p{L}, just those that are listed. Is there a way to just add hex values of these letters in my pattern? Also, is it posible to avoid /u, because I do not know if PHP is compiled with UTF support? – milosh Sep 03 '12 at 16:25

0 Answers0