p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Pro PHP (http://p2p.wrox.com/forumdisplay.php?f=96)
-   -   regular expression (http://p2p.wrox.com/showthread.php?t=12439)

Moharo April 29th, 2004 11:05 AM

regular expression
 
hi there

another silly question to ask.... what would be the regular expression syntax for any email address ending ONLY with ".edu"???



the genuine genius

skicrud April 29th, 2004 02:05 PM

found a solution

<?php
include ("header.php");
?>
<html>
<body>
<?php
$name='';
$value='';
if($HTTP_POST_VARS){
    while(list($lvar,$lvalue)=each($HTTP_POST_VARS)){
        if ((ereg("[^1]$",$lvar)) && (ereg("[^\d\w]$",$lvalue))){ //if var does not end in a 1 and

                                        //value not null
        //echo "$lvar=$lvalue<br>"; //echo the var and its value
        //echo "$lvar ";
        //$statement=$lvar;
        //echo "$statement<br>";
        $name=$name . $lvar . ","; //built var string
        $value=$value . $lvalue . "','";
        }
        //echo "$lvalue ";
    }
}
$length=strlen($name); //get length of string
$name=Substr($name,0,($length-1));
$name="($name)"; //strip out last comma
echo "$name<br>";
$length2=strlen($value);
$value=Substr($value,0,($length2-2));
$value="('$value)";
echo "$value<br>";
$sql="INSERT into msdsmasterlist $name VALUES $value ";
$result=mysql_query($sql);
echo $sql;
$num_rows=mysql_affected_rows();
echo $num_rows;
$errors=mysql_error();
echo $errors;












Daniel Walker April 30th, 2004 04:17 AM

Hmm. It may be a solution, but it does not seem to be a solution to Moharo's problem.

Moharo, is this any good to you?

"^[a-z0-9\._-]+@([a-z0-9][a-z0-9-]*[a-z0-9]\.)+([a-z]+\.)?edu$"

Moharo April 30th, 2004 04:44 AM

big thanx mr. Walker... peace

:D

the genuine genius


All times are GMT -4. The time now is 05:04 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.