我目前努力下面的“类型”的内容相匹配:如何匹配所有“类型”并正确地转义正则表达式?
(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);
但我得到一个未知的修饰词“\”的错误消息。
如何正确匹配所有类型?感谢任何提示!
的可能的复制[警告:预浸\ _replace():未知的修饰词 '\]'(https://stackoverflow.com/questions/ 20705399/warning-preg-replace-unknown-modifier) – revo
你需要在PHP中使用分隔符和正则表达式。 http://php.net/manual/en/regexp.reference.delimiters.php你还需要转义特殊的正则表达式字符'()'。 – chris85