Re: (another) regex difficulty
| From: | CPT John W. Holmes | Date: | Wed, 01 Oct 2003 16:27:15 +0000 |
| Subject: | Re: (another) regex difficulty | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-164573@lists.php.net to get a copy of this message | ||
From: <jonas_weber@gmx.ch>
> regular expressions
> the example below should turn any character exept "\*" (*= any char)
> into an "x":
>
> $term = preg_replace('/[^(\\\)+(.){1}]/', 'x', $term);
>
> but i guess because of the [brackets] the "." (period) is treated as
> character "." instead as metacharacter (that matches any char).
>
> anyone knows how to work around this?
Maybe...
$term = preg_replace('/[^\\]./','x',$term);
which would replace any character that's NOT a \ followed by any other
character with an x...
Not tested, of course. :)
---John Holmes...