In follow-up to my previous question, I want to replace every instance of an ALL-CAPS* word with a link of the following format:
dictionary.com/browse/<TERM>
The preg_replace
call I am using is this:
$content = preg_replace('#[A-Z][A-Z]+#', '<a href="//dictionary.com/browse/$1">$1</a>', $content);
Using http://gskinner.com/RegExr, it appears I have my regex correct, and that it should be replacing on each find.
Have I done something wrong, either in the preg_replace
call, or pehaps in the registration of the plugin/filter to the Wordpress API?
Full context of the call:
function define_filter($content){
$content = preg_replace('#[A-Z][A-Z]+#', '<a href="//dictionary.com/browse/$1">$1</a>', $content);
}
add_filter('the_content', 'define_filter');
* I'm using the [A-Z][A-Z]+
syntax to ensure I do not match words like "I" and "A"