Regex in MySql - replace between Tags including Tags
Posted
by
user998163
on Stack Overflow
See other posts from Stack Overflow
or by user998163
Published on 2012-06-30T15:09:08Z
Indexed on
2012/06/30
15:15 UTC
Read the original article
Hit count: 377
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?
© Stack Overflow or respective owner