Possible Duplicate:
PHP Regex Get Text Between BBCode Tags
I have a text like:
[lang_de]Content in German[/lang_de][lang_en]Content in English[/lang_en].
I want to replace all text between [lang_en] and [/lang_en] including the opening and closing language tag.
This is my current regex:
UPDATE wp_posts SET post_content = '" . addslashes(preg_replace("/[lang_en](.*)[\/lang_en]/", '', $row['post_content'])) . "' WHERE ID = " . $row['ID']
With this regex, I do not get a valid results. It also replaces in html tags and so on.
What would be the correct regex?
This is a text example:
[lang_de]
<!--more-->
<div class="s-desc">
<br/>
Länge: 3:50 min | Tempo: 125 bpm
<p>
Text<br/>
</p>
<p>
<a href="#">LoFi-Version zum Testeinsatz in Ihrem Projekt hier downloaden</a>. (Rechstklick-->Ziel speichern unter...)<br/>
Die Nutzung dieser LoFi-Version ist ausschließlich für Testzwecke erlaubt!
</p>
</div>
[/lang_de]
[lang_en]<!--more-->
<div class="s-desc">
<br/>
Length: 3:50 min | Tempo: 125 bpm
<p>
Text<br/>
</p>
<p>
<a href="#">Download a lofi-version to test with your project here</a>. (right-click-->save target as...)<br/>
The usage of this lofi-version is permitted for testing purposes only!
</p>
</div>
[/lang_en]
The result shall look like this:
<!--more-->
<div class="s-desc">
<br/>
Länge: 3:50 min | Tempo: 125 bpm
<p>
Text<br/>
</p>
<p>
<a href="#">LoFi-Version zum Testeinsatz in Ihrem Projekt hier downloaden</a>. (Rechstklick-->Ziel speichern unter...)<br/>
Die Nutzung dieser LoFi-Version ist ausschließlich für Testzwecke erlaubt!
</p>
</div>
Simple test here.