需要正则表达式来选择html标签的否定模式选择 [英] Need regex to select the negative pattern selection of html tags

查看:115
本文介绍了需要正则表达式来选择html标签的否定模式选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用regex模式来查找除html标记之外的文本,

(<\s*[^>]*>)

文字是

This is simple html text <span class='simple'>simple simple text text</span> text

结果应为

This is simple html text simple simple text text text

请检查以下链接

https://regex101.com/r/cD8nG4/217

解决方案

在您提供的示例中,使用已有的正则表达式查找HTML标记要容易得多,然后将找到的字符串替换为空字符串./p>

我已经做过几次了,它的工作就像一种魅力.

I need the regex pattern where it finds the text other than the html tags,

(<\s*[^>]*>)

And the text is

This is simple html text <span class='simple'>simple simple text text</span> text

Result should be

This is simple html text simple simple text text text

Please check the below link

https://regex101.com/r/cD8nG4/217

解决方案

In the example you gave, it is much easier to find the HTML tags with the regex you already have, and then replace the found strings with empty strings.

I have done that several times, and it works like a charm.

这篇关于需要正则表达式来选择html标签的否定模式选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆