PHP常用正则表达式

//用户名必须为字母、数字与下划线
if (!preg_match('/^\w+$/i', $username))

 

//验证邮箱格式是否正确
if (!preg_match('/^[\w\.]+@\w+\.\w+$/i', $useremail))

 

//手机号必须为11位数字,且为1开头
if (!preg_match('/^1\d{10}$/i', $usermobile))

posted @ 2015-03-12 01:03  besti  阅读(129)  评论(0编辑  收藏  举报