最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Regex match up to the LAST occurrence of a pattern (e.g. <div>) BEFORE another matching pattern (e.g.

programmeradmin0浏览0评论

In other words, there can be no other occurrence of the pattern between the end of the match and the second pattern. This needs to be implemented in a single regular expression.

In my specific case I have a page of HTML and need to extract all the content between

<w-block-content><span><div>

and

</div></span></w-block-content>

where

  • the elements might have attributes
  • the HTML might be formatted or not - there might be extra white space and newlines
  • there may be other content between any of the above tags, including inner div elements within the above outer div. But you can assume each <w-block-content> element
    • contains ONLY ONE direct child <span> child (i.e. it may contain other non-span children)
      • which contains ONLY ONE direct <div> child
        • which wraps the content that must be extracted

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论