简体   繁体   中英

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

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.

我想我已经解决了

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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