RE: [PHP] String formatting using preg_replace
| From: | John W. Holmes | Date: | Tue, 13 May 2003 17:57:17 +0000 |
| Subject: | RE: [PHP] String formatting using preg_replace | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-147476@lists.php.net to get a copy of this message | ||
> > Objective : Strip out all occurrences of the following from a string
:
> > /?<>,.;':"`!@#$%^&*()1234567890-+=\|
> > ....and replace them with nothing
>
> Don't know what you're trying to achieve but it may be easier to just
> match
> the stuff that you do want and ignore the rest.
Yeah... how about:
$new_str = preg_replace('/[^a-z]/i','',$old_str);
which will replace anything that's NOT a-z (case insensitive).
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/