简体   繁体   English

regex-replace-text-outside-html<a>标签</a>

[英]regex-replace-text-outside-html <a> tags

I have this HTML:我有这个 HTML:

"This is simple html <a href='google.com'>text</a><span class='simple'>simple simple text text</span> text"

I need to match only words that are outside HTML tag.我只需要匹配 HTML 标签之外的单词。 I mean if I want to match “simple” and “text” I should get the results only from inside of HTML tags except for tag.我的意思是如果我想匹配“简单”和“文本”,我应该只从 HTML 标签内部获取结果,除了标签。

I was close with this regexp (text|simple)(?![^<]*>|[^<>]*<\\/) but I am excluding all the html tags.我很接近这个正则表达式(text|simple)(?![^<]*>|[^<>]*<\\/)但我排除了所有的 html 标签。

我想我已经解决了

(?!([^<]+)?>)(?!<a[^>]*?>)(\text\b)(?![^<]*?</a>)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM