So, I'm trying to edit a dictionary file with regex. My current regex can match the two closest strings (and everything between them). The problem is that I need to find only those strings that have a particular string between them. I tried to combine negative lookahead and positive lookahead, but without success.
Here's my current regex:
<b>(?:(?!<\/?b>).)*?<\/b>(?:(?!<\/?b>).)*?<font color=darkslategray>.*?<\/font>
An example with a small part of the dictionary file: https://regex101.com/r/yV1zC3/1
And I need to capture the closest occurrences of <b> </b>
and <font color=darkslategray> </font>
tags, but only if there are <VR> </VR>
tags between them. The result should be:
<b>na·ive</b><br><div style="padding-left:0.5em;">(<VR><span style="color:#006400;font-style:italic">or</span> <b>na·ïve</b></VR>) <font color=darkslategray>/nɑˈiːv, naıˈiːv/</font>
<b>na·ïve·té</b> (<VR><span style="color:#006400;font-style:italic">also</span> <b>na·ive·te</b> <span style="color:#006400;font-style:italic">or</span> <b>na·ive·té</b></VR>) <font color=darkslategray>/nɑˌiːvˈteı, naıˌiːvˈteı/</font>
<b>na·ive·ty</b> (<VR><span style="color:#006400;font-style:italic">also</span> <b>na·ïve·ty</b></VR>) <font color=darkslategray>/nɑˈiːvəti, naıˈiːvəti/</font>
Is it even possible to do with regex?