函數 validateEmail($email)
{ return eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0- 9-]+(.[_a-z0-9-]+)*@[a-z0- 9-]+ (.[a-z0-9-]+)*(.[a-z]{2,3})$", $email);
}
函數 validateURL($url)
{ return eregi("^((ht|f)tp://)((([a-z0-9-]+(.[a- z0-9-]+)*(.[a-z]{2,3}))|(([0-9]{1,3}.){3}([0-9]{1,3}) ))((/|?)[a-z0-9~#%&'_+=:?.-]*)*)$", $url);
}
函數convertURLS($text)
{ $text = eregi_replace("((ht|f)tp://www.|www.)([a-z0-9-]+( .[a-z0-9-]+)*(.[a-z]{2,3})((/|?)[a-z0-9~#%&\/'_+=:?.-] *)*)", "http://www.\3", $text);
$text = eregi_replace("((ht|f)tp://)((([a-z0-9-]+(.[a-z0-9-]+)*(.[a-z] {2,3}))|(([0-9]{1,3}.){3}([0-9]{1,3})))((/|?)[a-z0- 9~#%&'_+=:?.-]*)*)", "
\0", $text);
回傳$text;
}
函數convertMail($text)
{ $text = eregi_replace("([_a-z0-9-1)( ) +)*@[a- z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3}))", "
\0", $text);
返回$text;
}
函數convertAllLinks($text)
{ $text = ConvertURLS($text);
$text = ConvertMail($text);
返回$text;
}
?
以上就介紹了windowslivemail Email+URL的判斷和自動轉換函數,包括windowslivemail方面的內容,希望對PHP教程有興趣的朋友有所幫助。