Help with preg_match_all function

I am using an rss to html script to convert my RSS feed to HTML on a web page and it has a post processing feature that will do “anything” I am trying to have it search the content of the RSS and look for the keyword “airlines” and when it finds it change it to <b>airlines</b> basically add a bold tag to it. This is the example for modifying img tags but after reading the link to preg_match_all and searching google I am only more confused. I am hoping it is a quick modification for someone here.


<?php
// We MUST keep this classname.
class SimplePie_PostProcess
{
	// Function name MUST be the same as the template tag we're processing, all lowercase, and MUST accept a single string parameter.
	function item_content($s)
	{
		// Match all images in the content.
		preg_match_all('/<img([^>]*)>/i', $s, $matches);
 
		// Clear out the variable.
		$s = '';
 
		// Loop through all of the *complete* matches (stored in $matches[0]).
		foreach ($matches[0] as $match)
		{
			// Add the images (only) back to $s.
			$s .= $match . '<br />';
		}
 
		// Return $s back out to the plugin.
		return $s;
	}
}
?>

Hopefully the function itself is not the cause for confusion, but the crazy /<img([^>]*)>/i syntax used for the first parameter? The best cure for that would be to have a look at a regular expressions tutorial to get your eye in.

A basic way of replacing text might look something like:


<?php 
// We MUST keep this classname. 
class SimplePie_PostProcess 
{ 
    // Function name MUST be the same as the template tag we're processing, all lowercase, and MUST accept a single string parameter. 
    function item_content($s) 
    {
        // Wrap "airline" (case-insensitive) in <b> tags
        return preg_replace('/\\b(airline)\\b/i', '<b>$1</b>', $s);
    } 
} 
?>

I hope I’m not intruding but I know another excellent REGEX documentation called Perl Regular Expression Mastery. The whole thing can also be downloaded in PDF format. That really explains how the PCRE engine works, which is great for anyone trying to learn REGEX.

Thanks for the help and the tips.