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); ?> Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.