Re: Regular Expression
| From: | Andrey Hristov | Date: | Tue, 13 Nov 2001 08:16:44 +0000 |
| Subject: | Re: Regular Expression | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-74385@lists.php.net to get a copy of this message | ||
if (count(preg_grep('/(([0-9a-zA-Z]+)|\-)/',array($fn,$sn)))==2){
}
Andrey Hristov
IcyGEN Corporation
http://www.icygen.com
BALANCED SOLUTIONS
----- Original Message -----
From: "Jason G." <blair@nb.net>
To: <Adam.Whitehead@compsm.com.au>; <php-general@lists.php.net>
Sent: Tuesday, November 13, 2001 10:18 AM
Subject: Re: [PHP] Regular Expression
> I am just learning them, but I think something like this may be in order...
> I know that you would use the | (or) operator.
>
> if(! (ereg('^[a-z|A-Z|0-9|\-]+$', $fn) &&
> (ereg('^[a-z|A-Z|0-9|\-]+$', $fs)))
> {
> Either $fn or $sn failed the match
> }
>
> -Jason Garber
> IonZoft.com
>
>
>
> At 04:41 PM 11/13/2001 +0930, Adam.Whitehead@compsm.com.au wrote:
> >Hi All-
> >
> >This is probably very simple for most of you.
> >I have the following statement
> >
> >if ((ereg('[^([:alnum:]|\-)]',$fn)) || (ereg('[^([:alnum:]|\-)]',$sn)))
> >{
> >// Do something here
> >}
> >
> >What it's doing is checking two variables to make sure they contain only
> >alphanumeric
> >characters.
> >
> >I have a requirement that hyphens (-) be allowed in $fn and $sn as well.
> >What do I need
> >to add to the regular expression to allow hyphens?
> >
> >I know this is a relatively silly question. I plan on buying a book on
> >regular expressions
> >today and learning as much as I need to know about building them.
> >
> >Cheers.
> >
> >Regards,
> >Adam Whitehead
> >Systems Developer - Computer Support and Maintenance
> >Ph. (08) 8936 3164 ** Mobile (0411) 241 120
> >E-mail: adam.whitehead@compsm.com.au
> >
> >
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> >For additional commands, e-mail: php-general-help@lists.php.net
> >To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>