Re: preg_match
| From: | chris smith | Date: | Sat, 01 Apr 2006 05:09:28 +0000 |
| Subject: | Re: preg_match | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-233041@lists.php.net to get a copy of this message | ||
On 4/1/06, Benjamin D Adams <badams@ambrosiasw.com> wrote:
> I'm trying to check a string for ../
> <?php
> if(preg_match("/..//i", $string)){
> echo "string has ../";
> }
> ?>
>
> Can't get it to work can anyone help?
Since / is your delimiter you need to escape it.
Also '.' means anything so you need to escape that as well.
if (preg_match('/\.\.\//', $string)) ...
What are you trying to achieve? There may be a better way than using a
regular expression.
--
Postgresql & php tutorials
http://www.designmagick.com/