regex-replace-text-outside-html <a> tags

时间:2019-04-04 11:17:33

标签: java html regex replace

I have this 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. I mean if I want to match “simple” and “text” I should get the results only from inside of HTML tags except for tag.

I was close with this regexp (text|simple)(?![^<]*>|[^<>]*<\/) but I am excluding all the html tags.

1 个答案:

答案 0 :(得分:0)

我想我已经解决了

stream_context_create