hello,
okay, your solution works with my example, but not with my html-template.
It does only find my placeholder when it is inside the last block.
When you test it with my following html-template and the placeholder
{#xmreisepop_re isepreistext_1_ 3#}
you will get no match, but there should be one.
Regular expression:
<%OPTIONAL%>(?! .*<%OPTIONAL%>) (.*?){#xmreisep op_reisepreiste xt_1_3#}(.*?)<% \/OPTIONAL%>
html-template:
<td class="cssxmrei seleistehg"><ta ble border="0" cellspacing="0"
cellpadding="0" width="190">
<!-- Titelbild -->
<tr><td class="cssxmrei setitelbild"><x img src="images/1pixt.gif" width="180"
height="180" alt="" border="0"></td></tr>
<!-- Reisepreis -->
<tr><td class="cssxmrei seleistehead">R eistermin und Preis:</td></tr>
<tr>
<td><table width=100% border="0" cellspacing="0" cellpadding="0" >
<%OPTIONAL%>
<tr><td class="cssxmrei sepopreisetermi n2"
colspan="2">{#x mreisepop_reise terminvon_1_1#}-{#xmreisepop_re iseterminbis_1_ 1#}</td></tr>
<tr><td
class="cssxmrei sepopreisepreis text"><b>{#xmre isepop_reisepre istext_1_1#}</b></td></tr>
<tr><td align="right"
class="cssxmrei sepopreisepreis "><b>€&nbs p; {#xmrei sepop_reiseprei s_1_1#}</b></td></tr>
<%/OPTIONAL%>
<%OPTIONAL%>
<tr><td
class="cssxmrei sepopreisepreis text">{#xmreise pop_reisepreist ext_1_2#}</td></tr>
<tr><td align="right"
class="cssxmrei sepopreisepreis ">€ & nbsp;{#xmreisep op_reisepreis_1 _2#}</td></tr>
<%/OPTIONAL%>
<tr><td
class="cssxmrei sepopreisepreis text">{#xmreise pop_reisepreist ext_1_3#}</td></tr>
<%OPTIONAL%>
<tr><td align="right"
class="cssxmrei sepopreisepreis ">€ & nbsp;{#xmreisep op_reisepreis_1 _3#}</td></tr>
<%/OPTIONAL%>
<%OPTIONAL%>
<tr><td
class="cssxmrei sepopreisepreis text">{#xmreise pop_reisepreist ext_1_4#}</td></tr>
<tr><td align="right"
class="cssxmrei sepopreisepreis ">€ & nbsp;{#xmreisep op_reisepreis_1 _4#}</td></tr>
<tr><td colspan="2" class="cssxmrei sereiseleistung en"><img src="1pixt.gif"
width="1" height="1" alt="" border="0"></td></tr>
<%/OPTIONAL%>
<!-- -->
<%OPTIONAL%>
<tr><td
class="cssxmrei sepopreisepreis text">{#xmreise pop_reisepreist ext_1_3#}</td></tr>
<tr><td class="cssxmrei sepopreisetermi n2"
colspan="2">{#x mreisepop_reise terminvon_2_1#}-{#xmreisepop_re iseterminbis_2_ 1#}</td></tr>
<tr><td
class="cssxmrei sepopreisepreis text"><b>{#xmre isepop_reisepre istext_2_1#}</b></td></tr>
<tr><td align="right"
class="cssxmrei sepopreisepreis "><b>€&nbs p; {#xmrei sepop_reiseprei s_2_1#}</b></td></tr>
<%/OPTIONAL%>
<%OPTIONAL%>
<tr><td
class="cssxmrei sepopreisepreis text">{#xmreise pop_reisepreist ext_2_2#}</td></tr>
<tr><td align="right"
class="cssxmrei sepopreisepreis ">€ & nbsp;{#xmreisep op_reisepreis_2 _2#}</td></tr>
<%/OPTIONAL%>
<%OPTIONAL%>
<tr><td
class="cssxmrei sepopreisepreis text">{#xmreise pop_reisepreist ext_2_3#}</td></tr>
<tr><td align="right"
class="cssxmrei sepopreisepreis ">€ & nbsp;{#xmreisep op_reisepreis_2 _3#}</td></tr>
<%/OPTIONAL%>
<%OPTIONAL%>
<tr><td
class="cssxmrei sepopreisepreis text">{#xmreise pop_reisepreist ext_2_4#}</td></tr>
<tr><td align="right"
class="cssxmrei sepopreisepreis ">€ & nbsp;{#xmreisep op_reisepreis_2 _4#}</td></tr>
<tr><td colspan="2" class="cssxmrei sereiseleistung en"><img src="1pixt.gif"
width="1" height="1" alt="" border="0"></td></tr>
<%/OPTIONAL%>
<!-- -->
<%OPTIONAL%>
<tr><td class="cssxmrei sepopreisetermi n2"
colspan="2">{#x mreisepop_reise terminvon_3_1#}-{#xmreisepop_re iseterminbis_3_ 1#}</td></tr>
<tr><td
class="cssxmrei sepopreisepreis text"><b>{#xmre isepop_reisepre istext_3_1#}</b></td></tr>
<tr><td align="right"
class="cssxmrei sepopreisepreis "><b>€&nbs p; {#xmrei sepop_reiseprei s_3_1#}</b></td></tr>
<%/OPTIONAL%>
<%OPTIONAL%>
<tr><td
class="cssxmrei sepopreisepreis text">{#xmreise pop_reisepreist ext_3_2#}</td></tr>
<tr><td align="right"
class="cssxmrei sepopreisepreis ">€ & nbsp;{#xmreisep op_reisepreis_3 _2#}</td></tr>
<%/OPTIONAL%>
<%OPTIONAL%>
<tr><td
class="cssxmrei sepopreisepreis text">{#xmreise pop_reisepreist ext_3_3#}</td></tr>
<tr><td align="right"
class="cssxmrei sepopreisepreis ">€ & nbsp;{#xmreisep op_reisepreis_3 _3#}</td></tr>
<%/OPTIONAL%>
<%OPTIONAL%>
<tr><td
class="cssxmrei sepopreisepreis text">{#xmreise pop_reisepreist ext_3_4#}</td></tr>
<tr><td align="right"
class="cssxmrei sepopreisepreis ">€ & nbsp;{#xmreisep op_reisepreis_3 _4#}</td></tr>
<tr><td colspan="2" class="cssxmrei sereiseleistung en"><img src="1pixt.gif"
width="1" height="1" alt="" border="0"></td></tr>
<%/OPTIONAL%>
<!-- -->
<%OPTIONAL%>
<tr><td class="cssxmrei sepopreisetermi n2"
colspan="2">{#x mreisepop_reise terminvon_4_1#}-{#xmreisepop_re iseterminbis_4_ 1#}</td></tr>
<tr><td
class="cssxmrei sepopreisepreis text"><b>{#xmre isepop_reisepre istext_4_1#}</b></td></tr>
<tr><td align="right"
class="cssxmrei sepopreisepreis "><b>€&nbs p; {#xmrei sepop_reiseprei s_4_1#}</b></td></tr>
<%/OPTIONAL%>
<%OPTIONAL%>
<tr><td
class="cssxmrei sepopreisepreis text">{#xmreise pop_reisepreist ext_4_2#}</td></tr>
<tr><td align="right"
class="cssxmrei sepopreisepreis ">€ & nbsp;{#xmreisep op_reisepreis_4 _2#}</td></tr>
<%/OPTIONAL%>
<%OPTIONAL%>
<tr><td
class="cssxmrei sepopreisepreis text">{#xmreise pop_reisepreist ext_4_3#}</td></tr>
<tr><td align="right"
class="cssxmrei sepopreisepreis ">€ & nbsp;{#xmreisep op_reisepreis_4 _3#}</td></tr>
<%/OPTIONAL%>
<%OPTIONAL%>
<tr><td
class="cssxmrei sepopreisepreis text">{#xmreise pop_reisepreist ext_4_4#}</td></tr>
<tr><td align="right"
class="cssxmrei sepopreisepreis ">€ & nbsp;{#xmreisep op_reisepreis_4 _4#}</td></tr>
<tr><td colspan="2" class="cssxmrei sereiseleistung en"><img src="1pixt.gif"
width="1" height="1" alt="" border="0"></td></tr>
<%/OPTIONAL%>
<!-- -->
<%OPTIONAL%>
<tr><td class="cssxmrei sepopreisetermi n2"
colspan="2">{#x mreisepop_reise terminvon_5_1#}-{#xmreisepop_re iseterminbis_5_ 1#}</td></tr>
<tr><td
class="cssxmrei sepopreisepreis text"><b>{#xmre isepop_reisepre istext_5_1#}</b></td></tr>
<tr><td align="right"
class="cssxmrei sepopreisepreis "><b>€&nbs p; {#xmrei sepop_reiseprei s_5_1#}</b></td></tr>
<%/OPTIONAL%>
<%OPTIONAL%>
<tr><td
class="cssxmrei sepopreisepreis text">{#xmreise pop_reisepreist ext_5_2#}</td></tr>
<tr><td align="right"
class="cssxmrei sepopreisepreis ">€ & nbsp;{#xmreisep op_reisepreis_5 _2#}</td></tr>
<%/OPTIONAL%>
<%OPTIONAL%>
<tr><td
class="cssxmrei sepopreisepreis text">{#xmreise pop_reisepreist ext_5_3#}</td></tr>
<tr><td align="right"
class="cssxmrei sepopreisepreis ">€ & nbsp;{#xmreisep op_reisepreis_5 _3#}</td></tr>
<%/OPTIONAL%>
<%OPTIONAL%>
<tr><td
class="cssxmrei sepopreisepreis text">{#xmreise pop_reisepreist ext_5_4#}</td></tr>
<tr><td align="right"
class="cssxmrei sepopreisepreis ">€ & nbsp;{#xmreisep op_reisepreis_5 _4#}</td></tr>
<tr><td colspan="2" class="cssxmrei sereiseleistung en"><img src="1pixt.gif"
width="1" height="1" alt="" border="0"></td></tr>
<%/OPTIONAL%>
<!-- -->
</table></td>
</tr>
<!-- Leistungen -->
<tr><td class="cssxmrei seleistehead">L eistungen:</td></tr>
<tr><td class="cssxmrei sereiseleistung en"><table border="0" cellspacing="0"
cellpadding="0" width="180">
<!-- Nachfolgenden Block markieren für eine Neuformatierung -->
<tr valign="bottom" ><td class="cssxmrei sereiseleistung en"><ul>
<!-- ###Format1### -->{#xmreise_reis eleistungen#}<!-- ###Format1### -->
</ul></td></tr>
</table></td></tr>
</table></td>
<td> </td>
</tr>
<!-- Reise Ratser -->
<tr>
<td><img src="1pixt.gif" width="30" height="1" alt="" border="0"></td>
<td><img src="1pixt.gif" width="480" height="1" alt="" border="0"></td>
<td><img src="1pixt.gif" width="10" height="1" alt="" border="0"></td>
<td><img src="1pixt.gif" width="190" height="1" alt="" border="0"></td>
<td><img src="1pixt.gif" width="30" height="1" alt="" border="0"></td>
</tr>
</table>
</body>
</html>
_______________ _______________ _______________ __
"Brad Kent" <bk***********@ yahoo.com> schrieb im Newsbeitrag
news:7a******** *************** **@posting.goog le.com...
want something like this?
$regex = '|<foo[^<>]*>(?!.*<foo[^<>]*>).*?</foo>|si';
preg_match($reg ex,$string,$mat ches);
the above was allows for nested "foo" tags... only matches the
innermost one.. sounded like that's what you wanted..
if you want more than the 1st match.. shoudl use preg_match_all. ..
BTW, here's a great general regex site:
http://www.regular-expressions.info/
"Lui Ali" <lu********@gmx .de> wrote in message
news:<2p******* *****@uni-berlin.de>... Hello,
Problem:
I want to get the whole text between the opening tag <%OPTIONAL%>
and the closing tag <%/OPTIONAL%>.
The right block is found by (and contains) the placeholder
{#xmreisepop_re isepreistext_1_ 3#}.
<%OPTIONAL%> and <%/OPTIONAL%> are not allowed to be inside these tags
again.
My first idea was:
<%OPTIONAL%>(.* ?){#xmreisepop_ reisepreistext_ 1_3#}(.*?)<%\/OPTIONAL%>
But this does not work with the following peace of text, because it takes
the first <%OPTIONAL%> before and the first
<%/OPTIONAL%> after the placeholder.
<%OPTIONAL%>
...bla bla bla....
<%/OPTIONAL%>
...
<%OPTIONAL%>
...
{#xmreisepop_re isepreistext_1_ 3#}
...
<%/OPTIONAL%>
Then I tried it with this version:
<%OPTIONAL%>(.* )(?!(<%OPTIONAL %>|<%\/OPTIONAL%>)){#x mreisepop_reise preistext_1_3#} (.*?)<%\/OPTIONAL%>
No success!
Can someone help me?