我目前正在努力匹配以下内容"类型":
(Type): multiplechoice
(Category): 0
(Random answers): 0
(Question): Which of the following is true about pre-test imagery?
(Type): multiplechoice
(Category): 0
(Random answers): 1
(Question): Which of the following is not true about the TMJ?
我在尝试:
preg_match_all("(Type)\:(.+?)\n", $content, $types);
但是我得到了一个未知的修饰符" \"作为错误消息。
如何正确匹配所有类型?谢谢你的任何提示!
答案 0 :(得分:1)
这应该做,假设后面有空格:
preg_match_all('/\((.+?)\): (.*)?/i', $subject, $array, PREG_PATTERN_ORDER);