input string:
<sometag> valid content .....
....line break some开发者_如何学Go more valid content</sometag>
output string:
valid content.....
......line break some more valid content
Please let me know how to do it, thanks.
You can use the strip_tags()
PHP function instead of a regular expression. See manual.
<?php
$str = "<sometag> valid content .....
....line break some more valid content</sometag>";
echo strip_tags($str);
//valid content .....
//....line break some more valid content
?>
$string = '<sometag> valid content .....
....line break some more valid content</sometag>';
$string = preg_replace('/<[^>]+>/', '', $string);
$oldstring = "<sometag> valid content ..... ....line break some more valid content</sometag>";
$newstring = preg_replace('/\b<sometag>\b/', '', $oldstring);
$newstring = preg_replace('/\b</sometag>\b/', '', $newstring);
$newstring = preg_replace('<br/>', '', $newstring);
assuming by line break you mean <br/>
精彩评论