Hallo! $text = "hare krishna"; $text = preg_replace('/\W+/', '-', $text); PHP: $text return hare-krishna, as expected with DASH. But if I use Cyrillic, the result is not the same, no DASH. I tried $text = preg_replace('/\w+/ui', '-', $text); PHP: and it is not yet. Can anyone help me how to separate words with a hyphen in Latin and Cyrillic? Thanks!
If replacing spaces with dashes is what you are looking to achieve, str_replace will work on all languages.
I want to filter invalid characters for words like ()*&^% and so on. I wont only words, separated by DASH. I will use the expression for URL address. Thanks
Without an actual sample of the text and the result you are trying to achieve, It is hard to test which functions you should use. Have a look at the overloaded mb_* functions, maybe one of them can help you: http://uk3.php.net/manual/en/mbstring.overload.php
Or you can use u modifier: $text = preg_replace('/\W+/mu', '-', $text); PHP: Variant 2: $text = preg_replace('/[^a-zа-Ñ0-9]+/miu', '-', $text); PHP: Regards