Re: Replacing chars l ike: º OR ¿
| From: | Alexander Skwar | Date: | Mon, 18 Mar 2002 15:29:36 +0000 |
| Subject: | Re: Replacing chars l ike: º OR ¿ | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-88937@lists.php.net to get a copy of this message | ||
»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:
askwar@charente.de
iso-top.de - Die günstige Art an Linux Distributionen zu kommen
Uptime: 1 day 4 hours 22 minutes