【发布时间】:2013-11-30 05:04:24
【问题描述】:
我正在尝试从字符串中提取 em 标记。在 http://www.phpliveregex.com/ 上,我的正则表达式有效,但在我的代码中它返回 0(未找到匹配项)。
$regex = "/<em class=\"correct_response\".*\/em>/";
echo preg_match($regex, $string);
/* sample values for the data in $string are
toggle('clue_J_1_1', 'clue_J_1_1_stuck', '<em class="correct_response">3M</em><br /><br /> <table width="100%"><tr><td class="right">Ashok</td></tr></table>')
toggle('clue_J_2_2', 'clue_J_2_2_stuck', '<em class="correct_response">Confucius</em><br /><br /><table width="100%"><tr><td class="right">Ashok</td></tr></table>')
*/
我做错了什么?谢谢。
【问题讨论】:
标签: php regex preg-match