Re: regex problem
| From: | Daniel J. Rychlik | Date: | Sun, 01 Jun 2003 01:38:59 +0000 |
| Subject: | Re: regex problem | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-149692@lists.php.net to get a copy of this message | ||
If I wanted to remove <script></script> tags from my form as well as <html>
tags, would I use a preg_match function or is their another simple funtion
that does this ?
-Dan
----- Original Message -----
From: "Jim Lucas" <phplist@zonedzero.net>
To: "Daniel J. Rychlik" <drychlik@tcsconsult.com>;
<php-general@lists.php.net>
Sent: Saturday, May 31, 2003 6:04 PM
Subject: Re: [PHP] regex problem
> Are you wanting the $_POST['nums1'] to have only numbers, -, ., #, : ????
>
> Is this what you are trying to match. if so, try this.
>
> if ( preg_match("/[^0-9\#\:\.\-]/", $_POST['nums1']) ) {
> throw error()
> }
>
> This will match anything that is not a number or one of the other special
> chars that are in the pattern to be matched.
>
> Therefor, if it does find anything that is not in the pattern to be
matched
> it will return true and then it will enter the if statement instead of
> skipping over it.
>
> Jim Lucas
> ----- Original Message -----
> From: "Daniel J. Rychlik" <drychlik@tcsconsult.com>
> To: <php-general@lists.php.net>
> Sent: Saturday, May 31, 2003 11:46 AM
> Subject: [PHP] regex problem
>
>
> Hello,,
>
> I have a preg_match issue matching numbers. I am currently using
>
> !preg_match ('/([0-9\-\.\#:])/', $_POST['nums1']
> throw error[]
>
> This fails if you use something like ' asdf ' but if you use ' asdf789 '
it
> passes false and does not throw an error.
> This is not the obvious solution.... I know its a problem in my regular
> expression. Should I ONLY be using
>
> ' /([0-9])/ ' , ?
>
> Thanks in advance.
> Daniel
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>