473,830 Members | 2,199 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extracting text between tags is tricky!

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?

Jul 17 '05 #1
5 1712
By the way, I (want to) use regular expressions.

"Lui Ali" <lu********@gmx .de> schrieb im Newsbeitrag
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?

Jul 17 '05 #2
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?

Jul 17 '05 #3
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>&euro;&nbs p;&nbsp;{#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 ">&euro;&nbsp;& 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 ">&euro;&nbsp;& 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 ">&euro;&nbsp;& 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>&euro;&nbs p;&nbsp;{#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 ">&euro;&nbsp;& 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 ">&euro;&nbsp;& 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 ">&euro;&nbsp;& 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>&euro;&nbs p;&nbsp;{#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 ">&euro;&nbsp;& 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 ">&euro;&nbsp;& 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 ">&euro;&nbsp;& 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>&euro;&nbs p;&nbsp;{#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 ">&euro;&nbsp;& 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 ">&euro;&nbsp;& 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 ">&euro;&nbsp;& 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>&euro;&nbs p;&nbsp;{#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 ">&euro;&nbsp;& 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 ">&euro;&nbsp;& 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 ">&euro;&nbsp;& 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>&nbsp;</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?

Jul 17 '05 #4
Hi,

{#xmreisepop_re isepreistext_1_ 3#}(?=((?!\<%OP TIONAL%>).)*?\< %\/OPTIONAL%>)

would do that job if PHP would not display: "PHP has encountered a Stack
overflow"...... .


"Lui Ali" <lu********@gmx .de> schrieb im Newsbeitrag
news:2p******** ****@uni-berlin.de...
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>&euro;&nbs p;&nbsp;{#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 ">&euro;&nbsp;& 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 ">&euro;&nbsp;& 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 ">&euro;&nbsp;& 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>&euro;&nbs p;&nbsp;{#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 ">&euro;&nbsp;& 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 ">&euro;&nbsp;& 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 ">&euro;&nbsp;& 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>&euro;&nbs p;&nbsp;{#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 ">&euro;&nbsp;& 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 ">&euro;&nbsp;& 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 ">&euro;&nbsp;& 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>&euro;&nbs p;&nbsp;{#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 ">&euro;&nbsp;& 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 ">&euro;&nbsp;& 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 ">&euro;&nbsp;& 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>&euro;&nbs p;&nbsp;{#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 ">&euro;&nbsp;& 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 ">&euro;&nbsp;& 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 ">&euro;&nbsp;& 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>&nbsp;</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?


Jul 17 '05 #5
Make sure you're using the "s" modifier so that the "." will match new-lines
also, "{" and "}" are special chars that need escaped.

"Lui Ali" <lu********@gmx .de> wrote in message news:<2p******* *****@uni-berlin.de>...
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%>

Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
5191
by: Markus Ernst | last post by:
Hello I have a regex problem, spent about 7 hours on this now, but I don't find the answer in the manual and googling, though I think this must have been discussed before. I try to simply extract the title and meta tags of a valid HTML page as an array: function extract_html($filename)
1
1557
by: Philippe C. Martin | last post by:
Hi, How would one go about extracting the pickle module from Python (ex: to make a .a or a .dll) ? Thanks Philippe
7
2006
by: Jasper Bryant-Greene | last post by:
I have three tables: `photos`, `tags` and `tags_photos`. The `photos` table contains a unique ID and a bunch of other stuff, the `tags` table contains a unique ID and a tag name, and the `tags_photos` contains the photo ID and the tag ID for an association between a tag and a photo. In other words, any photo may have many tags and any tag may have many photos.
5
2962
by: Michael Hill | last post by:
Hi, folks. I am writing a Javascript program that accepts (x, y) data pairs from a text box and then analyzes that data in various ways. This is my first time using text area boxes; in the past, I have used individual entry fields for each variable. I would now like to use text area boxes to simplify the data entry (this way, data can be produced by another program--FORTRAN, "C", etc.--but analyzed online, so long as it is first...
1
2809
by: Cognizance | last post by:
Hi gang, I'm an ASP developer by trade, but I've had to create client side scripts with JavaScript many times in the past. Simple things, like validating form elements and such. Now I've been assigned the task of extracting content from a given HTML page. If anyone's familiar with the Yahoo! Store order confirmation screen, I need to be able to grab the total amount from the table to the right-hand side. (Sample File:
6
1855
by: RSH | last post by:
Hi, I have quite a few .DAT data files that i need to extract the data out of. When i open the files in a text editor I see all of the text that I need to get at BUT there are a lot of junk (binary?) characters and white space in non logical formatting positions. Here is a small sample of what the data looks like: 0~ 0501101010512505011132451235 >   ô ô
4
3081
by: james.eaton | last post by:
I have an XML Schema Document (.xsd) that contains documentation tags (specifically, custom tags subordinate xsd:appinfo). These documentation tags contain strings that may contain ampersands. I have written an XSL Document (.xls) to extract these values and output an XML document including them on the screen. When I copy and paste the result to an XML file (.xml) and test for well-formedness, I get an error telling me that a semicolon...
9
2474
by: sebzzz | last post by:
Hi, I work at this company and we are re-building our website: http://caslt.org/. The new website will be built by an external firm (I could do it myself, but since I'm just the summer student worker...). Anyways, to help them, they first asked me to copy all the text from all the pages of the site (and there is a lot!) to word documents. I found the idea pretty stupid since style would have to be applied from scratch anyway since we...
3
9820
by: Magnus.Moraberg | last post by:
Hi, I wish to extract all the words on a set of webpages and store them in a large dictionary. I then wish to procuce a list with the most common words for the language under consideration. So, my code below reads the page - http://news.bbc.co.uk/welsh/hi/newsid_7420000/newsid_7420900/7420967.stm a welsh language page. I hope to then establish the 1000 most commonly
0
10489
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10525
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10202
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9314
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7746
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6950
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5617
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3076
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.