<?php
$regex = '/(?=<!--\sBEGIN\s(.*?)\s-->(.*?)(?=<!--\sEND\s(.*?)\s-->))/s';
$string = '<!-- BEGIN switch legend -->
<ul id="picture_legend">
<li><img src="{FORUM_NEW_IMG}" alt="{L_NEW_POSTS}" />{L_NEW_POSTS}</li>
<li><img src="{FORUM_IMG}" alt="{L_NO_NEW_POSTS}" />{L_NO_NEW_POSTS}</li>
<li><img src="{FORUM_LOCKED_IMG}" alt="{L_LOCKED}" />{L_LOCKED}</li>
</ul>
<!-- END switch legend -->
<!-- BEGIN switch default -->
<ul id="picture_legend">
<li><img src="{FORUM_NEW_IMG}" alt="{L_NEW_POSTS}" />{L_NEW_POSTS}</li>
<li><img src="{FORUM_IMG}" alt="{L_NO_NEW_POSTS}" />{L_NO_NEW_POSTS}</li>
<li><img src="{FORUM_LOCKED_IMG}" alt="{L_LOCKED}" />{L_LOCKED}</li>
</ul>
<!-- END switch default -->';
preg_match_all($regex,$string,$matches,PREG_OFFSET_CAPTURE
|PREG_SET_ORDER
);
PD9waHAKICAkcmVnZXggPSAnLyg/PTwhLS1cc0JFR0lOXHMoLio/KVxzLS0+KC4qPykoPz08IS0tXHNFTkRccyguKj8pXHMtLT4pKS9zJzsKICAkc3RyaW5nID0gJzwhLS0gQkVHSU4gc3dpdGNoIGxlZ2VuZCAtLT4KICAgIDx1bCBpZD0icGljdHVyZV9sZWdlbmQiPgoJICAgIDxsaT48aW1nIHNyYz0ie0ZPUlVNX05FV19JTUd9IiBhbHQ9IntMX05FV19QT1NUU30iIC8+e0xfTkVXX1BPU1RTfTwvbGk+CgkgICAgPGxpPjxpbWcgc3JjPSJ7Rk9SVU1fSU1HfSIgYWx0PSJ7TF9OT19ORVdfUE9TVFN9IiAvPntMX05PX05FV19QT1NUU308L2xpPgoJICAgICA8bGk+PGltZyBzcmM9IntGT1JVTV9MT0NLRURfSU1HfSIgYWx0PSJ7TF9MT0NLRUR9IiAvPntMX0xPQ0tFRH08L2xpPgogICAgPC91bD4KPCEt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