haku Posted January 22, 2010 Share Posted January 22, 2010 First, here is the text I am working off of: <div id="block-menu-menu-top-menu" class="block block-menu"> <h2>Top Menu</h2> <div class="content"> <ul class="menu"><li class="leaf first dhtml-menu "><a href="/about_us" title="" id="dhtml_menu-264-1">教室案内</a></li> <li class="leaf dhtml-menu "><a href="/courses" title="" id="dhtml_menu-265-1">コース</a></li> <li class="leaf dhtml-menu "><a href="/course_fees" title="" id="dhtml_menu-267-1">コース料金</a></li> <li class="leaf dhtml-menu "><a href="/jidou_eiken" title="" id="dhtml_menu-266-1">児童英検</a></li> <li class="leaf dhtml-menu "><a href="/galleries" title="" id="dhtml_menu-268-1">ギャラリー</a></li> <li class="leaf dhtml-menu "><a href="/testimonials" title="" id="dhtml_menu-270-1">生徒の声</a></li> <li class="leaf last dhtml-menu "><a href="/access" title="" id="dhtml_menu-269-1">お問合せ・アクセス</a></li> </ul> </div> </div> I'm trying to pull out the <ul> tags, and everything in between, using this: preg_match('/<ul\b[^>]*>(.*?)<\/ul>/i', $text, $matches); For whatever reason, it's not working. I can grab the opening <ul> tag, or the closing </ul> tag by themselves, but if I try to grab the content in between, I get nothing. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/189418-why-isnt-this-regex-working/ Share on other sites More sharing options...
cags Posted January 22, 2010 Share Posted January 22, 2010 By default the . doesn't match newline characters, you will need to add the s modifier (next to the i at the end of your pattern). Quote Link to comment https://forums.phpfreaks.com/topic/189418-why-isnt-this-regex-working/#findComment-999875 Share on other sites More sharing options...
haku Posted January 22, 2010 Author Share Posted January 22, 2010 Ahhh, thats why. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/189418-why-isnt-this-regex-working/#findComment-999887 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.