<?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>blog.autopsy.se &#187; RegExp</title>
	<atom:link href="http://blog.autopsy.se/tag/regexp/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.autopsy.se</link>
	<description>basically; it sucks. everything sucks. but.. in a good way..</description>
	<lastBuildDate>Wed, 23 Nov 2011 18:25:21 +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>Perl 5.8.8 sucks, or the lack of Perl 5.10 on my box sucks! Really</title>
		<link>http://blog.autopsy.se/2009/01/perl-588-sucks-or-the-lack-of-perl-510-on-my-box-sucks-really/</link>
		<comments>http://blog.autopsy.se/2009/01/perl-588-sucks-or-the-lack-of-perl-510-on-my-box-sucks-really/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 01:44:34 +0000</pubDate>
		<dc:creator>ube</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Named Capture]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[RegExp]]></category>
		<category><![CDATA[Sucks! (Really!)]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://blog.autopsy.se/?p=55</guid>
		<description><![CDATA[Been struggling with a regexp using perl since I couldn't get sed to work as I wanted (mainly "+" sucks with sed). These are my tests: # echo cold.case.S01E12.qweqwe &#124;perl -pe 's/^(?:(.*)\.(\d+)x(\d+).*)&#124;(?:(.*)\.S(\d+)E(\d+)).*$/\1 \2 \3 \4 \5 \6 \7/' cold.case    01 12 #echo cold_case.1x12 &#124; perl -pe 's/^(?:(.*)\.(\d+)x(\d+).*)&#124;(?:(.*)\.S(\d+)E(\d+)).*$/\1 \2 \3 \4 \5 \6 \7/' cold_case 1 [...]]]></description>
			<content:encoded><![CDATA[<p>Been struggling with a regexp using perl since I couldn't get sed to work as I wanted (mainly "+" sucks with sed).</p>
<p><span id="more-55"></span></p>
<p>These are my tests:</p>
<p># echo cold.case.S01E12.qweqwe |perl -pe 's/^(?:(.*)\.(\d+)x(\d+).*)|(?:(.*)\.S(\d+)E(\d+)).*$/\1 \2 \3 \4 \5 \6 \7/'<br />
cold.case    01 12<br />
#echo cold_case.1x12 | perl -pe 's/^(?:(.*)\.(\d+)x(\d+).*)|(?:(.*)\.S(\d+)E(\d+)).*$/\1 \2 \3 \4 \5 \6 \7/'<br />
cold_case 1 12</p>
<p>Notice the three spaces in front of cold.case? It's because I can't get perl to do an alternate match. A friend came up with the following line:<br />
perl -pe 's/(?:^(?&lt;a&gt;.*)\.(?&lt;b&gt;[0-9])+x(?&lt;c&gt;[0-9]+).*$)|(?:^(?&lt;a&gt;.*)\.S(?&lt;b&gt;[0-9]+)E(?&lt;c&gt;[0-9]+).*$)/$+{a} $+{b} $+{c}/'<br />
Which works just fine, if you're running Perl 5.10, and I'm not! Or, it's not in the Gentoo repository yet. So I'll have to wait. Crap!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.autopsy.se/2009/01/perl-588-sucks-or-the-lack-of-perl-510-on-my-box-sucks-really/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>7 deadly sins of regexp</title>
		<link>http://blog.autopsy.se/2008/12/7-deadly-sins-of-regexp/</link>
		<comments>http://blog.autopsy.se/2008/12/7-deadly-sins-of-regexp/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 08:16:05 +0000</pubDate>
		<dc:creator>ube</dc:creator>
				<category><![CDATA[just for fun]]></category>
		<category><![CDATA[RegExp]]></category>

		<guid isPermaLink="false">http://blog.autopsy.se/?p=11</guid>
		<description><![CDATA[Lust /(.*?)/ Gluttony /(.{1,})\b/ Greed /^.*$/ Sloth http://www.amazon.com/Regular-Expression-Pocket-Reference-Expressions/dp/0596514271/ref=pd_bbs_sr_2?ie=UTF8&#38;s=books&#38;qid=1229670757&#38;sr=8-2 Wrath s/.*//g Envy FUCK IT! Pride /(\((?:[^()]++&#124;(?-1))*+\))/]]></description>
			<content:encoded><![CDATA[<p>Lust /(.*?)/<br />
Gluttony /(.{1,})\b/<br />
Greed /^.*$/<br />
Sloth http://www.amazon.com/Regular-Expression-Pocket-Reference-Expressions/dp/0596514271/ref=pd_bbs_sr_2?ie=UTF8&amp;s=books&amp;qid=1229670757&amp;sr=8-2<br />
Wrath s/.*//g<br />
Envy FUCK IT!<br />
Pride /(\((?:[^()]++|(?-1))*+\))/</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.autopsy.se/2008/12/7-deadly-sins-of-regexp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>validating user names sucks!</title>
		<link>http://blog.autopsy.se/2008/10/validating-user-names-sucks/</link>
		<comments>http://blog.autopsy.se/2008/10/validating-user-names-sucks/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 14:17:02 +0000</pubDate>
		<dc:creator>ube</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Code Poetry]]></category>
		<category><![CDATA[RegExp]]></category>

		<guid isPermaLink="false">http://blog.autopsy.se/?p=6</guid>
		<description><![CDATA[You know when you're writing any application, and you want to restrict the characters in the user name? Instead of checking for non allowed characters, look for allowed. Sounds strange? Not really, you'll understand: function checkname&#40;$string, $allowed&#41; &#123; $allowed = &#34;/[$allowed]/s&#34;; $string = preg_replace&#40;$allowed, &#34;&#34;, $string&#41;; if &#40; $string &#41; return FALSE; else return TRUE; [...]]]></description>
			<content:encoded><![CDATA[<p>You know when you're writing any application, and you want to restrict the characters in the user name? Instead of checking for non allowed characters, look for allowed. Sounds strange? Not really, you'll understand:</p>
<pre class="php"><span style="color: #000000; font-weight: bold;">function</span> checkname<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$string</span>, <span style="color: #0000ff;">$allowed</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
<span style="color: #0000ff;">$allowed</span> = <span style="color: #ff0000;">&quot;/[$allowed]/s&quot;</span>;
<span style="color: #0000ff;">$string</span> = <a href="http://www.php.net/preg_replace"><span style="color: #000066;">preg_replace</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$allowed</span>, <span style="color: #ff0000;">&quot;&quot;</span>, <span style="color: #0000ff;">$string</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$string</span> <span style="color: #66cc66;">&#41;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">FALSE</span>;
<span style="color: #b1b100;">else</span>
<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">TRUE</span>;
<span style="color: #66cc66;">&#125;</span></pre>
<p>So what you'll do is remove all allowed characters, and if there are any left in the string the user has chosen an invalid username. Ofcourse it's regexp that does the trick. Using the code:</p>
<pre class="php"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> ! checkname<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$input</span>, <span style="color: #ff0000;">&quot;A-Za-z0-9_<span style="color: #000099; font-weight: bold;">\.</span>&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>
<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;Invalid username!&quot;</span>;
<span style="color: #b1b100;">else</span>
<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;Ok, lets go!</span></pre>
<p>We're allowing A-Z, a-z, 0-9, underscore and dots in the username.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.autopsy.se/2008/10/validating-user-names-sucks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

