I've constructed a RegEx query using Regex101regex preview.
The content I'm scanning looks like this:
<p>I am a paragraph<sup class="footnote-ref"><a href="#fn4" id="fnref4">[4]</a></sup>.</p>
<div class="inline_footnote"><sup class="inline_sup">[4]</sup>I am a footnote with the paragraph</a></div>
<div class="inline_footnote"><sup class="inline_sup">[4]</sup>I am a footnote with the paragraph</a></div>
<div class="inline_footnote"><sup class="inline_sup">[4]</sup>I am a footnote with the paragraph</a></div>
<div class="inline_footnote"><sup class="inline_sup">[4]</sup>I am a footnote with the paragraph</a></div>
The Regex I'm using looks like this:
(<p>.*?)(<a href="#fn4".*?>.*?<\/a>)(.*?<\/p>)((?:\s*<div class="inline_footnote">.*?<\/div>)*)
In the preview online it matches the footnote divs as one group (as I intend):
In 'live' javascript however the fourth group is absent.
Demo code in Js:
let searching_in = `<p>I am a paragraph<sup class="footnote-ref"><a href="#fn4" id="fnref4">[4]</a></sup>.</p>
<div class="inline_footnote"><sup class="inline_sup">[4]</sup>I am a footnote with the paragraph</a></div>
<div class="inline_footnote"><sup class="inline_sup">[4]</sup>I am a footnote with the paragraph</a></div>
<div class="inline_footnote"><sup class="inline_sup">[4]</sup>I am a footnote with the paragraph</a></div>
<div class="inline_footnote"><sup class="inline_sup">[4]</sup>I am a footnote with the paragraph</a></div>`
let regex = new RegExp( `(<p>.*?)(<a href="#fn4".*?>.*?<\/a>)(.*?<\/p>)((?:\s*<div class="inline_footnote">.*?<\/div>)*)` )
console.log( regex.exec( searching_in ) )
Any help is appreciated, I have a headache now.