pianoparadise Posted August 31, 2008 Share Posted August 31, 2008 I am trying to get $match[1] to have '<li>AAAAA' stored, but the code is not working. How can I fix this? <?php $data=' <ul> <li>AAAAAA <ul> <li>BBBBB</li> </ul> </li> </ul>'; $regex = '/\<ul\>(.*)\<ul\>/i'; preg_match($regex,$data,$match); echo $match[1]; var_dump($match); ?> Link to comment https://forums.phpfreaks.com/topic/122054-preg-question-with-regex-not-working/ Share on other sites More sharing options...
effigy Posted September 2, 2008 Share Posted September 2, 2008 . will not match new lines without the /s modifier. You also need a lazy quantifier: /<ul>(.*?)<ul>/is Link to comment https://forums.phpfreaks.com/topic/122054-preg-question-with-regex-not-working/#findComment-631942 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.