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:
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: and here:
2. I think that I will need a if/then loop to prevent the substitution from being made if the string is already encased in <a> or tags, but I am not sure how to go ...information you may need. Thanks in advance!
An example from what I am using:
Code:
$post['message'] = preg_replace('/(70-292)/i', '<a href="[URL unfurl="true"]http://www.mcseworld.com/a/1932266569/"[/URL] 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: and here:
2. I think that I will need a if/then loop to prevent the substitution from being made if the string is already encased in <a> or tags, but I am not sure how to go ...information you may need. Thanks in advance!