与特定的类HTML我有这个测试字符串删除所有的HTML标签,除了使用正则表达式
@[email protected] <span class="mention">@test</span> @[email protected] <span class="mention">@test</span> [email protected] Test @test.com <br> <a></a> <hr></hr> <span>dsfsfdsdfsdfs asdf </span> <span>test</span> <a>f</a>
而且我希望能去除所有标签,同时留下自己的内容只有当阶级提跨度。为了会留下如下:
@[email protected] <span class="mention">@test</span> @[email protected] <span class="mention">@test</span> [email protected] Test @test.com dsfsfdsdfsdfs asdf test f
这是据我得到了,但它仍然无法正常工作
/(?!<span class="mention".*?<\/span>)(<([a-z]*)>(.[^<>]*|)<(\/[a-z]*)>)/g
任何帮助将不胜感激!
http://stackoverflow.com/a/1732454/2640017 – 2014-08-28 05:38:36
不要用正则表达式解析HTML。 – 2014-08-28 05:38:51