<?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>Joey Rivera &#187; regex</title>
	<atom:link href="http://www.joeyrivera.com/tag/regex/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.joeyrivera.com</link>
	<description>Blogging about PHP, Actionscript, MySQL, and other interests.</description>
	<lastBuildDate>Fri, 02 Dec 2011 03:55:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Quick update to Uploader &#8211; fixed some minor bugs</title>
		<link>http://www.joeyrivera.com/2008/quick-update-to-uploader-fixed-some-minor-bugs/</link>
		<comments>http://www.joeyrivera.com/2008/quick-update-to-uploader-fixed-some-minor-bugs/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 19:42:44 +0000</pubDate>
		<dc:creator>Joey</dc:creator>
				<category><![CDATA[Uploader]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://www.joeyrivera.com/?p=207</guid>
		<description><![CDATA[Two bugs were found and addressed. The first bug happened while trying to upload a link. I dropped a URL on the Uploader and the app got stuck in the &#8220;Thinking&#8221; phase. After some troubleshooting, I noticed the page for the URL did not have a &#60;title&#62; tag so the app was sending the PHP [...]]]></description>
			<content:encoded><![CDATA[<p>Two bugs were found and addressed. The first bug happened while trying to upload a link. I dropped a URL on the Uploader and the app got stuck in the &#8220;Thinking&#8221; phase. After some troubleshooting, I noticed the page for the URL did not have a &lt;title&gt; tag so the app was sending the PHP page an empty &#8216;name&#8217; variable causing the PHP page to stop executing during the validation phase.  The fix was to assign a default name to the link if no title tag is present. In these cases, I&#8217;ll manually give the link a proper title.</p>
<p>The second issue also had to do with the &lt;title&gt; tag. In this case, the HTML did have a title tag but the case was different that what I was looking for. My code was looking for all lowercase characters and the tag in the HTML was in uppercase. My first thought was to do a .toLowerCase() on the HTML code but then all the titles would be in lower case and wouldn&#8217;t look as presentable (ex: the size of our planet vs The Size of Our Planet). After giving this some more thought, it seemed using regex would be the cleanest solution. A quick Google search returned <a title="Regular Expressions" href="http://www.troubleshooters.com/codecorn/littperl/perlreg.htm" target="_blank">this page</a> which said by adding an &#8216;i&#8217; to the end of my regex, the search would be case insensitive. I gave it a try and it worked like a charm.</p>
<p>Before Code:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">var</span> <span class="kw3">start</span>:<span class="kw3">Number</span> = s.<span class="kw3">indexOf</span><span class="br0">&#40;</span><span class="st0">&#8216;&lt;title&gt;&#8217;</span><span class="br0">&#41;</span>;<br />
<span class="kw2">var</span> <span class="kw3">end</span>:<span class="kw3">Number</span> = s.<span class="kw3">indexOf</span><span class="br0">&#40;</span><span class="st0">&#8216;&lt;/title&gt;&#8217;</span><span class="br0">&#41;</span>;<br />
<span class="kw2">var</span> title:<span class="kw3">String</span> = s.<span class="kw3">substr</span><span class="br0">&#40;</span><span class="kw3">start</span> + <span class="nu0">7</span>, <span class="kw3">end</span> &#8211; <span class="kw3">start</span> &#8211; <span class="nu0">7</span><span class="br0">&#41;</span>;</div>
<p>After Code:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">var</span> <span class="kw3">start</span>:<span class="kw3">Number</span> = s.<span class="me1">search</span><span class="br0">&#40;</span>/&lt;title&gt;/i<span class="br0">&#41;</span>;<br />
<span class="kw2">var</span> <span class="kw3">end</span>:<span class="kw3">Number</span> = s.<span class="me1">search</span><span class="br0">&#40;</span>/&lt;\/title&gt;/i<span class="br0">&#41;</span>;<br />
<span class="kw2">var</span> title:<span class="kw3">String</span> = s.<span class="kw3">substr</span><span class="br0">&#40;</span><span class="kw3">start</span> + <span class="nu0">7</span>, <span class="kw3">end</span> &#8211; <span class="kw3">start</span> &#8211; <span class="nu0">7</span><span class="br0">&#41;</span>;</div>
]]></content:encoded>
			<wfw:commentRss>http://www.joeyrivera.com/2008/quick-update-to-uploader-fixed-some-minor-bugs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

