How to remove only html tags in a string?
php, regex
Solution
Sorry I had not validate enough.
I have checked php5-cli expression below.
(?:<|<)\/?([a-zA-Z]+) *[^<\/]*?(?:>|>)
PHP code goes:
#!/usr/bin/php
<?php
$str = "<html></html>
a<b 1<2 3>1
<body>1>2</body>
<style file=\"'googe'\" alt=\"google\">hello world</style>
<have a good efghijknopqweryuip[]asdfgghjkzxcv bnm,.me>hello world<> google com</s>
<a se=\"font: googe;\">abcde</a>";
echo "text--->".preg_replace('/(?:<|<)\/?([a-zA-Z]+) *[^<\/]*?(?:>|>)/', '', $str)."\n";
?>
Result:
text--->
a<b 1<2 3>1
1>2
hello world
hello world<> google com
abcde
Problem
I have written code for removing HTML tags, but it is also removing `a<b` type of strings. I want it to not to remove strings like `2<3` or `a<b`. ``` $term="a<b"; echo "Text is--->".preg_replace('/(?:<|<).+?(?:>|>)/', '', $term); ``` How do I remove html tags in a string, without removing LT or GT?