Re: Regular Expression
| From: | Jason G. | Date: | Tue, 13 Nov 2001 08:18:06 +0000 |
| Subject: | Re: Regular Expression | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-74383@lists.php.net to get a copy of this message | ||
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