A while ago, i've built the following regular expression:
~(?:<a.*?</a>|\[url.*?\[/url]|\[/?[^]]++]|</?[^>]++>)(*SKIP)(*FAIL)|\bcdkey\s*-\s*.*\b~is
This matches every kind of cdkey-xxx that's NOT inside of a bbcode or a html tag. That works fine so far.
However, i can't make it work properly when including bbcodes and html tags. I thought, removing the front part is enough, but i seem to be wrong:
~\bcdkey\s*-\s*.*\b~is
With this regex,
<a href="https://www.google.de/#q=cdkey-0192xdasas" class="externalURL">https://www.google.de/#q=cdkey-0192xdasas</a>
becomes
<a href="https://www.google.de/#q=***>
and
[url]https://www.google.de/#q=cdkey-0192xdasas[/url]
becomes
[url]https://www.google.de/#q=***]
while the expected results are
<a href="https://www.google.de/#q=***" class="externalURL">https://www.google.de/#q=***</a>
and
[url]https://www.google.de/#q=***[/url]
I have no idea, how to fix that.
So, what i try to achieve is to replace
[url]https://www.google.de/#q=cdkey-0192xdasas[/url]
[url=https://www.google.de/#q=cdkey-0192xdasas]Test[/url]
[img]https://www.google.de/#q=cdkey-0192xdasas[/img]
[url="https://www.google.de/#q=cdkey-0192xdasas"]Test 3[/url]
https://www.google.de/#q=cdkey-0192xdasas
Another plaintext cdkey - bla
<a href="https://www.google.de/#q=cdkey-0192xdasas" class="externalURL">https://www.google.de/#q=cdkey-0192xdasas</a>
<a href='https://www.google.de/#q=cdkey-0192xdasas'>Le Google</a>
with
[url]https://www.google.de/#q=***[/url]
[url=https://www.google.de/#q=***]Test[/url]
[img]https://www.google.de/#q=***[/img]
[url="https://www.google.de/#q=***"]Test 3[/url]
Plaintext https://www.google.de/#q=***
Another plaintext ***
<a href="https://www.google.de/#q=***" class="externalURL">https://www.google.de/#q=***</a>
<a href='https://www.google.de/#q=***'>Le Google</a>