<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>Chumby.net</title>
	<link>http://chumby.net</link>
	<description>What's this?  I'm not telling.</description>
	<pubDate>Thu, 15 May 2008 21:28:54 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>Replacing whole words in strings in PHP</title>
		<link>http://chumby.net/2008/05/15/replacing-whole-words-in-strings-in-php/</link>
		<comments>http://chumby.net/2008/05/15/replacing-whole-words-in-strings-in-php/#comments</comments>
		<pubDate>Thu, 15 May 2008 21:28:38 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[php]]></category>

		<category><![CDATA[regular expressions]]></category>

		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://chumby.net/2008/05/15/replacing-whole-words-in-strings-in-php/</guid>
		<description><![CDATA[I was recently tasked with creating a simple dirty word filter in PHP that relies on our blacklist of about 600 words.  The filter should simply replace the word with its character length in asterisks. 
My first attempt just used str_replace, but I quickly realized that even dirty words embedded in clean words would [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently tasked with creating a simple dirty word filter in PHP that relies on our blacklist of about 600 words.  The filter should simply replace the word with its character length in asterisks. </p>
<p>My first attempt just used <a href="http://www.php.net/str_replace">str_replace</a>, but I quickly realized that even dirty words embedded in clean words would get filtered.  For example, words like &#8220;glass&#8221; would get filtered to &#8220;gl***&#8221;.</p>
<p>The solution?  Regular expressions:<br />
<code><br />
function str_replace_word($needle,$replacement,$haystack){<br />
&nbsp;&nbsp;&nbsp;&nbsp;$pattern = &quot;/\b$needle\b/i&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;$haystack = preg_replace($pattern, $replacement, $haystack);<br />
&nbsp;&nbsp;&nbsp;&nbsp;return $haystack;<br />
}<br />
</code></p>
<p>The pattern is pretty simple, but not being very familiar with regular expressions, I had to do a couple Google searches before I found what I needed.</p>
<p>Here&#8217;s a simple breakdown of the pattern string:</p>
<h4>The pattern delimiter</h4>
<p>The pattern string begins and ends with a forward slash / character.  These two characters are called the pattern delimiter and are required by the preg_match function.  They can actually be any non-alphanumeric and non-backslash character, so you can pick your pattern delimiters to help with readability.<br />
<code><br />
$pattern = &#039;/\bMatch me\b/&#039;;<br />
$pattern = &#039;@\bMatch me\b@&#039;;<br />
$pattern = &#039;#\bMatch me\b#&#039;;<br />
</code></p>
<p>If you don&#8217;t supply a pattern delimiter, PHP will spit out this warning:<br />
<code><br />
Warning: preg_replace() [function.preg-replace]: Delimiter must not be alphanumeric or backslash in<br />
</code></p>
<h4>The word boundary \b</h4>
<p>The \b escape character acts as a word boundary.  For a nice explanation of this metacharacter, take a look at <a href="http://www.regular-expressions.info/wordboundaries.html">Jan Goyvaerts&#8217; excellent regular expression tutorial page</a>.</p>
<h4>The &#8216;i&#8217; at the end</h4>
<p>The &#8216;i&#8217; at the end of the pattern string just tells preg_match that the search should be case <strong>i</strong>nsensitive.</p>
]]></content:encoded>
			<wfw:commentRss>http://chumby.net/2008/05/15/replacing-whole-words-in-strings-in-php/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Campfest 2007</title>
		<link>http://chumby.net/2007/08/16/campfest-2007/</link>
		<comments>http://chumby.net/2007/08/16/campfest-2007/#comments</comments>
		<pubDate>Thu, 16 Aug 2007 22:21:27 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[camping]]></category>

		<category><![CDATA[hiking]]></category>

		<category><![CDATA[personal]]></category>

		<category><![CDATA[photography]]></category>

		<category><![CDATA[travel]]></category>

		<guid isPermaLink="false">http://chumby.net/2007/08/16/campfest-2007/</guid>
		<description><![CDATA[In early August of 2007, a group of 6 dapper young men set about on a week long trek through the wilderness of northern California and southern Oregon.  They spent 3 nights surrounded by bears in Crags Castle National Park near Mount Shasta and another 3 frigid nights in Crater Lake National Park.  [...]]]></description>
			<content:encoded><![CDATA[<p>In early August of 2007, a group of 6 dapper young men set about on a week long trek through the wilderness of northern California and southern Oregon.  They spent 3 nights surrounded by bears in <a href="http://www.chumby.net/gallery/v/camping_shasta/">Crags Castle National Park near Mount Shasta</a> and another 3 frigid nights in <a href="http://www.chumby.net/gallery/v/camping_crater_lake/">Crater Lake National Park</a>.  Barely surviving on pizza, steak and chili, the brave young men spent their last moments together bickering about the validity of Chrono Trigger as a real video game before succumbing to hip and knee pain and going home.</p>
<p><a href="http://chumby.net/gallery/v/camping_shasta/"><img src="http://chumby.net/gallery/d/7345-4/camping_shasta.jpg" alt="Mount Shasta" /></a><br />
Crags Castle National Park and Mount Shasta</p>
<p><a href="http://chumby.net/gallery/v/camping_crater_lake/"><img src="http://chumby.net/gallery/d/7537-4/camping_crater_lake.jpg" alt="Crater Lake National Park" /></a><br />
Crater Lake National Park</p>
]]></content:encoded>
			<wfw:commentRss>http://chumby.net/2007/08/16/campfest-2007/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Blizzcon &#8216;07</title>
		<link>http://chumby.net/2007/08/16/blizzcon-07/</link>
		<comments>http://chumby.net/2007/08/16/blizzcon-07/#comments</comments>
		<pubDate>Thu, 16 Aug 2007 22:11:13 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[personal]]></category>

		<category><![CDATA[photography]]></category>

		<category><![CDATA[travel]]></category>

		<guid isPermaLink="false">http://chumby.net/2007/08/16/blizzcon-07/</guid>
		<description><![CDATA[
Blizzon might as well be called WoWCon, and since I don&#8217;t play WoW, I had no idea what the panels were about.  I spent a good amount of time just walking around, taking pictures and following the cosplay girls.
Take a look at the gallery.
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.chumby.net/gallery/v/blizzcon07/"><img src="http://www.chumby.net/gallery/d/7761-4/blizzcon07.jpg" alt="COSPLAY GIRLS TEH HAWT" /></a></p>
<p>Blizzon might as well be called WoWCon, and since I don&#8217;t play WoW, I had no idea what the panels were about.  I spent a good amount of time just walking around, taking pictures and following the cosplay girls.</p>
<p>Take a look at the <a href="http://www.chumby.net/gallery/v/blizzcon07/">gallery</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://chumby.net/2007/08/16/blizzcon-07/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Chicago</title>
		<link>http://chumby.net/2007/08/16/chicago/</link>
		<comments>http://chumby.net/2007/08/16/chicago/#comments</comments>
		<pubDate>Thu, 16 Aug 2007 22:05:53 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[personal]]></category>

		<category><![CDATA[photography]]></category>

		<category><![CDATA[travel]]></category>

		<guid isPermaLink="false">http://chumby.net/2007/08/16/chicago/</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.chumby.net/gallery/v/chicago_2007/"><img src="http://www.chumby.net/gallery/d/7071-8/chicago_2007.jpg" alt="Chicago!" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://chumby.net/2007/08/16/chicago/feed/</wfw:commentRss>
		</item>
		<item>
		<title>San Francisco Roadtrip</title>
		<link>http://chumby.net/2007/06/05/san-francisco-roadtrip/</link>
		<comments>http://chumby.net/2007/06/05/san-francisco-roadtrip/#comments</comments>
		<pubDate>Tue, 05 Jun 2007 17:28:38 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[personal]]></category>

		<category><![CDATA[photography]]></category>

		<category><![CDATA[travel]]></category>

		<guid isPermaLink="false">http://chumby.net/2007/06/05/san-francisco-roadtrip/</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.chumby.net/gallery/v/san_francisco_roadtrip/"><img src="http://www.chumby.net/gallery/d/6777-4/san_francisco_roadtrip.jpg" alt="San Francisco Roadtrip" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://chumby.net/2007/06/05/san-francisco-roadtrip/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to fix moiré</title>
		<link>http://chumby.net/2007/04/10/how-to-fix-moire/</link>
		<comments>http://chumby.net/2007/04/10/how-to-fix-moire/#comments</comments>
		<pubDate>Tue, 10 Apr 2007 17:24:58 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[photography]]></category>

		<guid isPermaLink="false">http://chumby.net/2007/04/10/how-to-fix-moire/</guid>
		<description><![CDATA[http://www.dbphoto.net/techniques/
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.dbphoto.net/techniques/">http://www.dbphoto.net/techniques/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://chumby.net/2007/04/10/how-to-fix-moire/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Canyon Park Hike</title>
		<link>http://chumby.net/2007/04/09/canyon-park-hike/</link>
		<comments>http://chumby.net/2007/04/09/canyon-park-hike/#comments</comments>
		<pubDate>Mon, 09 Apr 2007 23:18:30 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[hiking]]></category>

		<category><![CDATA[personal]]></category>

		<category><![CDATA[photography]]></category>

		<category><![CDATA[travel]]></category>

		<guid isPermaLink="false">http://chumby.net/2007/04/09/canyon-park-hike/</guid>
		<description><![CDATA[
Canyon Park in Monrovia, CA.
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.chumby.net/gallery/v/canyon_park/"><img src="http://www.chumby.net/gallery/d/3458-5/canyon_park.jpg" alt="Canyon Park Hike - Monrovia, CA" /></a></p>
<p>Canyon Park in Monrovia, CA.</p>
]]></content:encoded>
			<wfw:commentRss>http://chumby.net/2007/04/09/canyon-park-hike/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Rocky Peak Hike</title>
		<link>http://chumby.net/2007/04/07/rocky-peak-hike/</link>
		<comments>http://chumby.net/2007/04/07/rocky-peak-hike/#comments</comments>
		<pubDate>Sat, 07 Apr 2007 18:08:05 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[hiking]]></category>

		<category><![CDATA[personal]]></category>

		<category><![CDATA[photography]]></category>

		<category><![CDATA[travel]]></category>

		<guid isPermaLink="false">http://chumby.net/2007/04/07/rocky-peak-hike/</guid>
		<description><![CDATA[
Starring Robert Redford, Meryl Streep and Tom Cruise.
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.chumby.net/gallery/v/rocky_peak/"><img src="http://www.chumby.net/gallery/d/3308-2/rocky_peak.jpg" alt="Rocky Peak Hike" /></a></p>
<p>Starring <a href="http://www.imdb.com/name/nm0000602/">Robert Redford</a>, <a href="http://www.imdb.com/name/nm0000658/">Meryl Streep</a> and <a href="http://www.imdb.com/name/nm0000129/">Tom Cruise</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://chumby.net/2007/04/07/rocky-peak-hike/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Moon</title>
		<link>http://chumby.net/2007/03/29/moon/</link>
		<comments>http://chumby.net/2007/03/29/moon/#comments</comments>
		<pubDate>Thu, 29 Mar 2007 21:12:55 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[photography]]></category>

		<guid isPermaLink="false">http://chumby.net/2007/03/29/moon/</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><a href="http://chumby.net/gallery/v/moon/"><img src="http://chumby.net/gallery/d/3222-2/moon.gif" alt="Moon animation"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://chumby.net/2007/03/29/moon/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP Excel Export class</title>
		<link>http://chumby.net/2007/03/27/php-excel-export-class/</link>
		<comments>http://chumby.net/2007/03/27/php-excel-export-class/#comments</comments>
		<pubDate>Tue, 27 Mar 2007 18:46:14 +0000</pubDate>
		<dc:creator>James</dc:creator>
		
		<category><![CDATA[php]]></category>

		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://chumby.net/2007/03/27/php-excel-export-class/</guid>
		<description><![CDATA[Following the code that I found here, I made a quick PHP4 class that creates a single sheet Excel file.  The class has a download() function that will send the appropriate headers for a binary download.
]]></description>
			<content:encoded><![CDATA[<p>Following the code that I found <a href="http://www.appservnetwork.com/modules.php?name=News&#038;file=article&#038;sid=8">here</a>, I made a quick PHP4 class that creates a single sheet Excel file.  The class has a download() function that will send the appropriate headers for a binary download.<br />
 <a href="http://chumby.net/2007/03/27/php-excel-export-class/#more-29" class="more-link">(more&#8230;)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://chumby.net/2007/03/27/php-excel-export-class/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
