💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
~~~ \D:非数字 等价于[^0-9] \d:数字 等价于[0-9] \W:非单词字符 等价于[^a-zA-Z0-9_] \w:单词字符 等价于[a-zA-Z0-9_] \S:非空字符 \s:空字符 空字符有 空格 制表符tab键 换行\n 回车\r i:ignore 忽略大小写 匹配时忽略大小写 U 和.*? 取消贪婪 /^ $/ ^开始 $结束 . 除\n 外的任意字符 .* 多次 * 零次 ? 零次或一次 .+ 一次或多次 + 一次 [] 集合 [\d|\w] {} 位数 {n} {n-m} () 后向引用 (把我取出来) #匹配137开头的手机号码 $pattern = '/^137\d{8}$/'; preg_match($pattern,$num,$match); return $match; #匹配邮箱 $pattern = '/^[\w]+@[\w]+\.com$/i'; preg_match($pattern,$email,$match); return $match; #获取多个img标签中的src值 $pattern='/<img.*?src="(.*?)".*?\/?>/'; /*preg_match:匹配中就会停止;preg_match_all全局匹配所有*/ preg_match_all($pattern,$str,$match); return $match; ~~~