Re: scanning for non alpha characters
| From: | Ernest E Vogelsinger | Date: | Thu, 14 Nov 2002 15:39:04 +0000 |
| Subject: | Re: scanning for non alpha characters | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-124445@lists.php.net to get a copy of this message | ||
At 16:32 14.11.2002, CJ spoke out and said:
--------------------[snip]--------------------
>I want to scan the variables passed from teh url of my script for non alpha
>characters. The variables should only consist of a-z A-Z 0-9 and spaces,
>full stops and commas (Basically I don't want scripts to be passed via the
>variable to the server)
>
>I've used perl a long time ago and its regular expressions seemed ideal for
>this kind of thing. Can enybody suggest a scrip to remove unwanted
>characters from my variable?
--------------------[snip]--------------------
<?php
$string = 'A string, with a lot of unwanted characters, more than 20 bytes
long...';
echo "$string<br>";
echo preg_replace('/[^a-zA-Z0-9]/',null,$string), '<br>';
?>
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/