标签: php regex
我需要从文本中获取特定的字符串,这些字符串的模式为XXXX-XXXX-XXXX
我尝试了这个/^[A-Z0-9]{4}+-[A-Z0-9]{4}+-[A-Z0-9.]{4}$/
/^[A-Z0-9]{4}+-[A-Z0-9]{4}+-[A-Z0-9.]{4}$/
$text = "some text : hello CF5C-D7C5-230B Hi"; echo preg_match("/^[A-Z0-9]{4}+-[A-Z0-9]{4}+-[A-Z0-9.]{4}$/", $text, $match);
0:不匹配,但应匹配CF5C-D7C5-230B