php正则表达式


字符串匹配 int preg_match($pattern,$str,$matches/null);有多个匹配结果时则只返回第1个匹配结果
     int preg_match_all($pattern,$str,$matches/null);返回所有成功匹配的元素
数组匹配   array preg_greg($pattern,$str)

"/^[\da-zA-Z][\w]{1,10}\@[\w]{1,6}\.[a-zA-Z]{2,4}$/"  //匹配邮箱

"/^[a-zA-Z0-9\x{4e00}-\x{9fa5}]$|^[a-zA-Z0-9\x{4e00}-\x{9fa5}][a-zA-Z0-9_\s\ \x{4e00}-\x{9fa5}\.]*[a-zA-Z0-9\x{4e00}-\x{9fa5}]$/u"
 //匹配中文,字母.数字
 
posted @ 2017-06-18 20:02  朴信惠  阅读(147)  评论(0)    收藏  举报