I'm trying to use the preg_replace command to do replacements of specific strings with the string as a URL. An example from what I am using:
PHP Code:
$post['message'] = preg_replace('/(70-292)/i', '<a href="http://www.mcseworld.com/a/1932266569/" target="_blank">\\1</a>', $post['message']);
This code would thus case the 70-292 string to be replaced with that URL.
I have two issues:
1. I cannot quite figure out how to get ONLY exact matches, no matter where they might appear in the post. I've been reading on this here:
http://www.php.net/manual/en/function.preg-replace.php and here:
http://www.php.net/manual/en/pcre.pattern.modifiers.php
2. I know that I will need a if/then loop to prevent the substitution from being made if the string is already encased in <a> or [URL] tags, but I am not sure how to go about that either.
I am currently using this in the functions_showthread.php file for vB 3.0.0 RC3, so no actual changes are being made to the data as the subs are done on the display end of things.
Thanks in advance!