Jump to content

Why isn't this regex working?


haku

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/189418-why-isnt-this-regex-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.