Hi Günther!
kann mir jemand verraten, wie ich diesen Code:
preg_replace("/(".$begriff.")/i", '<a href="'.$url.'">'."$1".'</a>', $text);
umschreibe, so dass bereits verlinkter Text nicht ersetzt wird?
Du suchst nach "negative look-ahead" und "negative look-behind".
In der Regextester-Hilfe sind diese beiden Begriffe zwar nicht erschöpfend aber mMn verständlich erklärt.
Der Aufbau des Regex wäre schematisch:
(?<!KEIN_LINK_STARTTAG)(BEGRIFF)(?!KEIN_LINK_ENDTAG)
MfG H☼psel
--
"It's amazing I won. I was running against peace, prosperity, and incumbency."
George W. Bush speaking to Swedish Prime Minister unaware a live television camera was still rolling, June 14, 2001
Selfcode: ie:% fl:( br:> va:) ls:& fo:) rl:? n4:& ss:| de:] js:| ch:? sh:( mo:) zu:)
"It's amazing I won. I was running against peace, prosperity, and incumbency."
George W. Bush speaking to Swedish Prime Minister unaware a live television camera was still rolling, June 14, 2001
Selfcode: ie:% fl:( br:> va:) ls:& fo:) rl:? n4:& ss:| de:] js:| ch:? sh:( mo:) zu:)