在 PHP 中可以使用 preg_match() 函数来检测一个字符串是否符合指定的正则表达式。 该函数的语法格式如下: preg_match(pattern, subject, matches, flags);