jQuery Regex Ignore Surrounding JS tags

I'm performing simple text search/replace on random HTML pages in jQuery, but I'm having issues ignoring terms that appear within an attribute, i.e. if my term is `jquery`, I would like to ignore all terms in ` jquery` while still hitting the one outside. Right now my code looks a little like this: $("div#content").html($("div#content").text().replace(/(jquery)/g, "stuff")); I've been looking at positive/negative lookahead/lookbehind, but I can't get it down right. I'm not able to use any external libraries besides jQuery, and I've seen [this post](https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags) already. I suppose one solution could be to use some indexOf magic to search the sections I want, but I don't know if this is efficient or feasible for quick text searching. Any suggestions would be greatly appreciated!
What about the terms inside the tags?

以上就是jQuery Regex Ignore Surrounding JS tags的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准