I have a html file containing ol list of items, each item has the pattern <li id=ref>xxxxx</li>
, the id "ref" is unique to this list. I want to add a closing </ol>
after the last item. so I use negative look-ahead to see if the next line has the same id (next line could be any text), if not, </ol>
tag will be inserted. this is my code
$html =~ s`(<li id="ref.*?</li>).*?(?!\<li id="ref)`$1</ol>`gm;
the code does not work no matter I use the modifier s
or m
at the end of the code.