<?xml version="1.0" encoding="UTF-8"?>
<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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PMA Media Group&#187; occurrences</title>
	<atom:link href="http://www.pmamediagroup.com/tag/occurrences/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pmamediagroup.com</link>
	<description>Unique Marketing Techniques and Strategies with Guaranteed Results!</description>
	<lastBuildDate>Thu, 29 Jul 2010 15:34:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Scan() Method for Regular Expressions</title>
		<link>http://www.pmamediagroup.com/2009/06/the-scan-method-for-regular-expressions/</link>
		<comments>http://www.pmamediagroup.com/2009/06/the-scan-method-for-regular-expressions/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 19:59:36 +0000</pubDate>
		<dc:creator>Chris Gunnels</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[hash]]></category>
		<category><![CDATA[occurrences]]></category>
		<category><![CDATA[regular expressions]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[scan method]]></category>
		<category><![CDATA[white space]]></category>

		<guid isPermaLink="false">http://www.pmamediagroup.com/?p=891</guid>
		<description><![CDATA[As I was writing a simple script to display the education I received from reading The Ruby Way 2nd Edition chapters 2 and 3, I found a really neat method that helped me complete my task. If you didn&#8217;t read the title of this blog post then your out of luck, but if you read [...]]]></description>
			<content:encoded><![CDATA[<p>As I was writing a simple script to display the education I received from reading The Ruby Way 2nd Edition chapters 2 and 3, I found a really neat method that helped me complete my task. If you didn&#8217;t read the title of this blog post then your out of luck, but if you read the title then you will know that I am talking about the <a href="http://www.ruby-doc.org/core/classes/String.html#M000827">scan()</a> method.</p>
<p>Back to my script, since I wanted to find the number of occurrences white space showed up in a given string I had to come up with a way to count white space. My first thought was to do some regular expression matching. Well after a little thought and a lot of reading, I found a this:<br />
<span id="more-891"></span><br />
<code><br />
answer = params[:string].scan(/(\s)/)<br />
puts answer.size<br />
</code><br />
Here&#8217;s a little breakdown of whats happening for those that don&#8217;t know. </p>
<p>GIVEN: params is a hash with the values that were posted via a form.<br />
Line 1: we are running the scan method on params[:string] which the value is a string. Then we pass scan method a regular expression that looks for any white space. Then the value of that is assigned to the local answer variable.<br />
Line 2: we print the answer&#8217;s size.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pmamediagroup.com/2009/06/the-scan-method-for-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/


Served from: www.pmamediagroup.com @ 2010-07-31 10:35:43 -->