<?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>Unwrongest &#187; regexp</title>
	<atom:link href="http://www.unwrongest.com/tag/regexp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.unwrongest.com</link>
	<description>Interaction Designer and Interface Developer</description>
	<lastBuildDate>Wed, 30 Jun 2010 11:24:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>You can&#8217;t validate email addresses with regular expressions</title>
		<link>http://www.unwrongest.com/blog/email-validation-regular-expressions/</link>
		<comments>http://www.unwrongest.com/blog/email-validation-regular-expressions/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 17:54:30 +0000</pubDate>
		<dc:creator>Jan Jarfalk</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[regexp]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://www.unwrongest.com/?p=351</guid>
		<description><![CDATA[There is no way of validating email addresses using regular expressions, but regexps and emails are still a useful mix. You can use a javascript email validation regexp to provide useful user feedback and prevent unnecessary typos.]]></description>
			<content:encoded><![CDATA[<p>There are several reasons to why there cannot be a perfect regular expression for validating email addresses. Firstly; the official standard, RFC 2822, just tells the basic email address syntax; john@doe.superman is a valid email address according to RFC 2822. Also the standard support characters, like &#8221; and [, that some email clients can't handle.</p>
<p>Secondly and more importantly; even if the email matches a perfect regular expression, there are no guarantees that the email address belongs to the user, or even exists.</p>
<p><iframe id="demo" style="border: 1px solid #ccc; width: 620px; height: 140px;" src="http://sandbox.unwrongest.com/forms/jquery.valid8.email.html"></iframe></p>
<p>With all that said I still believe live javascript-based email address checking using regular expressions is a good idea. You can use it to prevent users from doing unnecessary typos. You don't have to force them to pass the validation, just let them know if you suspect the email to be faulty. Try the demo, created with the Jquery plugin <a href="http://www.unwrongest.com/projects/valid8/">Valid8</a>, above and you will see what I mean.</p>
<pre class="brush:js">
/^[a-z0-9!#$%&#038;'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&#038;'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(aero|asia|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|pro|tel|travel.ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|er|es|et|eu|fi|fj|fk|fm|.fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|.il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)\b$/
</pre>
<p>Above is the regular expression I use. It is heavily based on a regexp from <a href="http://www.regular-expressions.info/email.html">regular-expressions.info</a></p>
<h2>How do I validate email addresses if not with regular expressions?</h2>
<p>Sending an email activation link is a perfect way of validating an email address. You email a link the user have to click on to complete the registration. The link should be disposable and often look like this: http://www.unwrongest.com/signup/?guid=8373629375284563</p>
<h2>Never trust client-side validation</h2>
<p>Lastly. Remember that you can never, ever, trust client-side javascript validation. It is very easy to tamper with. All validation you do on the client-side has to be done again on the server-side. Client-side validation should be mainly for the users sake.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.unwrongest.com/blog/email-validation-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
