少し前に、次の正規表現を作成しました。
~(?:<a.*?</a>|\[url.*?\[/url]|\[/?[^]]++]|</?[^>]++>)(*SKIP)(*FAIL)|\bcdkey\s*-\s*.*\b~is
これは、bbcode または html タグ内にないすべての種類の cdkey-xxx に一致します。これまでのところうまくいきます。
ただし、bbcode や html タグを含めると正しく動作しません。フロント部分を削除するだけで十分だと思いましたが、間違っているようです:
~\bcdkey\s*-\s*.*\b~is
この正規表現では、
<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=***>
と
[url]https://www.google.de/#q=cdkey-0192xdasas[/url]
になる
[url]https://www.google.de/#q=***]
期待される結果は
<a href="https://www.google.de/#q=***" class="externalURL">https://www.google.de/#q=***</a>
と
[url]https://www.google.de/#q=***[/url]
それを修正する方法がわかりません。
だから、私が達成しようとしているのは、交換することです
[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>
と
[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>