[PHP] Replacing chars like: º OR ¿
Hi there, I am still searching for a function which is replacing all chars not between [a-z] for exampe a province name like: minºaqah-ash-shamal¿yah into valid chars or just deleting them. There seems to be an endless amount of those chars. Thanx for any hint, andy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replacing chars like: º OR ¿
I am still searching for a function which is replacing all chars not between [a-z] for exampe a province name like: minºaqah-ash-shamal¿yah into valid chars or just deleting them. There seems to be an endless amount of those chars. This grep pattern: [\x80-\xFF] will match any high byte character - you could replace with null before displaying if just deleting is all you really need. why not specify the character set in your html so you can just leave them in? Cameron .:. -- Tantramar Interactive http://www.TantramarInteractive.com/ 16 Lorne St., Unit 3, Sackville, NB E4L 3Z7 Phone (506) 364-1097 Fax (506) 536-2409 All that glitters has a high refractive index. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replacing chars like: º OR ¿
»andy« sagte am 2002-03-18 um 14:22:47 +0100 : Hi there, I am still searching for a function which is replacing all chars not between [a-z] for exampe a province name like: minºaqah-ash-shamal¿yah into valid chars or just deleting them. There seems to be an endless amount of those chars. preg_replace('|[^a-z]||g', $string) or somesuch Alexander Skwar -- How to quote: http://learn.to/quote (german) http://quote.6x.to (english) Homepage: http://www.iso-top.de | Jabber: [EMAIL PROTECTED] iso-top.de - Die günstige Art an Linux Distributionen zu kommen Uptime: 1 day 2 hours 54 minutes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replacing chars like: º OR ¿
»Rasmus Lerdorf« sagte am 2002-03-18 um 07:12:21 -0800 : $new = preg_replace('/[^a-z]/i','',$old); Note that this will also get rid of the - in this case since you specifically asked for something that got rid of everything not a-z Yes. And to not get rid of the -, you need to specify it as the 1st charcter, or in your case, as the 2nd: $new = preg_replace('/[^-a-z]/i','',$old); How do you allow [ and ]? $new = preg_replace('/[^[]-a-z]/i','',$old); Alexander Skwar -- How to quote: http://learn.to/quote (german) http://quote.6x.to (english) Homepage: http://www.iso-top.de | Jabber: [EMAIL PROTECTED] iso-top.de - Die günstige Art an Linux Distributionen zu kommen Uptime: 1 day 4 hours 22 minutes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replacing chars like: º OR ¿
so whats the difference between yours and : $filename = ereg_replace ([^a-z^0-9^/.^=^/-], , $filename); Andy Alexander Skwar [EMAIL PROTECTED] schrieb im Newsbeitrag [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... »Rasmus Lerdorf« sagte am 2002-03-18 um 07:12:21 -0800 : $new = preg_replace('/[^a-z]/i','',$old); Note that this will also get rid of the - in this case since you specifically asked for something that got rid of everything not a-z Yes. And to not get rid of the -, you need to specify it as the 1st charcter, or in your case, as the 2nd: $new = preg_replace('/[^-a-z]/i','',$old); How do you allow [ and ]? $new = preg_replace('/[^[]-a-z]/i','',$old); Alexander Skwar -- How to quote: http://learn.to/quote (german) http://quote.6x.to (english) Homepage: http://www.iso-top.de | Jabber: [EMAIL PROTECTED] iso-top.de - Die günstige Art an Linux Distributionen zu kommen Uptime: 1 day 4 hours 22 minutes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replacing chars like: º OR ¿
»andy« sagte am 2002-03-18 um 17:00:16 +0100 : so whats the difference between yours and : $filename = ereg_replace ([^a-z^0-9^/.^=^/-], , $filename); You've got quite some ^ to much in there, I'd think. If I understand it correctly, you'd also not remove the ^ character, because you've mentioned this char quite sume times. The ^ has only a special meaning, if it's the 1st character in a [] group. Alexander Skwar -- How to quote: http://learn.to/quote (german) http://quote.6x.to (english) Homepage: http://www.iso-top.de | Jabber: [EMAIL PROTECTED] iso-top.de - Die günstige Art an Linux Distributionen zu kommen Uptime: 1 day 6 hours 26 minutes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php