bluewalrus
08-10-2010, 01:44 AM
So I thought I was getting a hang onto writing regular expressions but either I'm wrong or missing something.
I have this for my regular expression
<ol.*?>(.*?)<\/ol>
as this
$content = preg_replace('/<ol.*?>(.*?)<\/ol>/', '<div class="ol">$1</div>' . "<br />\n", $content);
I get my expected result but I can't use this function. I need to know how much content there is (how manye line items there are) inside that ol.
I tried
preg_match_all('/<ol.*?>(.*?)<\/ol>/', $content, $matches, PREG_SET_ORDER);
and
preg_replace_callback('/<ol.*?>(.*?)<\/ol>', "html_list", $content);
neither of which find the ordered list.
The ordered list is
<ol>
<li>Ordered List Item 1</li>
<li>Ordered List Item 2</li>
<li>Ordered List Item 3</li>
<li>Ordered List Item 4 5μL/mm 37°C.</li>
</ol>
The fourth item I'm parsing into the incorrect º and µ if that makes a difference. So does anyone see anything I'm doing wrong or know of a difference preg_replace_callback, preg_match_all, and just preg_replace? Thanks.
I have this for my regular expression
<ol.*?>(.*?)<\/ol>
as this
$content = preg_replace('/<ol.*?>(.*?)<\/ol>/', '<div class="ol">$1</div>' . "<br />\n", $content);
I get my expected result but I can't use this function. I need to know how much content there is (how manye line items there are) inside that ol.
I tried
preg_match_all('/<ol.*?>(.*?)<\/ol>/', $content, $matches, PREG_SET_ORDER);
and
preg_replace_callback('/<ol.*?>(.*?)<\/ol>', "html_list", $content);
neither of which find the ordered list.
The ordered list is
<ol>
<li>Ordered List Item 1</li>
<li>Ordered List Item 2</li>
<li>Ordered List Item 3</li>
<li>Ordered List Item 4 5μL/mm 37°C.</li>
</ol>
The fourth item I'm parsing into the incorrect º and µ if that makes a difference. So does anyone see anything I'm doing wrong or know of a difference preg_replace_callback, preg_match_all, and just preg_replace? Thanks.