This is a discussion on PCRE - National characters within the PHP General forums, part of the PHP Programming Forums category; Hi :) Now have i tried to solve my reg exp problem - but nothing seems to work. I want to find ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi :)
Now have i tried to solve my reg exp problem - but nothing seems to work. I want to find all non-letter chacters of a word - and replace it with nothing. It seems to work - but when I begin to add national characters to the strings - it doesnt work... A simple part of it could like like this <?php $foo = "ęble"; $bar = "Ja?"; echo preg_replace('/\W*/', '\1', $foo); //returns ble - hould return ęble echo preg_replace('/\W*/', '\1', $bar); //returns Ja ?> Isnt there a way to solve this problem? Or is \w limited to a-z? :) Regards, Johan |
|
|||
|
Funny, never realized that national characters were a part of the word
characters lot. You might want to try: <?php $foo = "ęble"; $bar = "Ja?"; echo preg_replace('/[^a-zA-Z]*/', '\1', $foo)."\n"; //returns ble echo preg_replace('/[^a-zA-Z]*/', '\1', $bar)."\n"; //returns Ja ?> --Nitin |