我目前努力下面的「類型」的內容相匹配:如何匹配所有「類型」並正確地轉義正則表達式?
(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