Being driven up the wall here. I've looked at other posts where there's a regex negative lookahead but for some reason I can't get it to work. Probably missing something very easy but after a couple of hours trying various options I need help!
So, I'm trying to find a pattern for preg_replace which searches through code for href links which IGNORES any containing a particular domain AND also IGNORES any which include a js reference called data-fancybox.
In the following it must ignore the first 3 which contain data-fancybox and also ignore #4 the youtube link. It should only find the last 2.
<a href="https://youtube.com/" data-fancybox><a href="https://example.com/" data-fancybox><a href="https://vimeo.com/" data-fancybox><a href="https://youtube.com/"><a href="https://example.com/"><a href="https://vimeo.com/">
When I try this:
<a href=.*((youtube|data-fancybox)).*>
It picks out the first 4 and ignores the last two. But when I try to turn this negative so it only picks out the last 2, it ends up picking them all out:
<a href=.*(?!(youtube|data-fancybox)).*>
Any help appreciated!!