Im using preg_replace to replace keywords in text with a href tag, my regex is working awesome, right now my code is:
$newstring2 = preg_replace(\"/\\p{L}*?\
How about this with negative lookahead. Regex
Explanation: capture all the keyword that is called text
and replace with it some link but don't capture those keywords that have after it.
$re = '/(text)(?!<\/a>)/m';
$str = 'this is sample text about something what is text.
this is sample text about something what is text.';
$subst = '$1';
$result = preg_replace($re, $subst, $str);
echo $result;
Output:
this is sample text about something what is text.
this is sample text about something what is text.
DEMO: https://3v4l.org/DVTB1