I check my websites articles for youtube links and auto-convert them into youtube html.
The problem is if someone wants to just link to a youtube url, the url will get parse with a link around it giving broken html.
This is using a BBCode parser I created using this for urls:
[url=address]text[/url]
This is the current regex:
~(?:http|https|)(?::\/\/|)(?:www.|)(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))([\w\-]{11})[a-z0-9;:@#?&%=+\/\$_.-]*~i
So, I tried adding in this to the start:
(?<!\[url=)
To look like:
~(?<!\[url=)(?:http|https|)(?::\/\/|)(?:www.|)(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))([\w\-]{11})[a-z0-9;:@#?&%=+\/\$_.-]*~i
So that if it detected the url bbcode section right before it, to not parse it into youtube html, but it seems to not work.
It will act as if my negative lookbehind isn't there, and will process the youtube url as normal.
This is the url in question:
[url=https://www.youtube.com/watch?v=jHnvVX_T1AA]
So it should not pick that up, since it is preceded by the url bbcode.
What am I doing wrong?