<?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>Blue Cap Development Studio &#187; VB.NET</title>
	<atom:link href="http://www.bluecapstudio.com/blog/category/vb-net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bluecapstudio.com/blog</link>
	<description>Just another development studio</description>
	<lastBuildDate>Fri, 11 Dec 2009 05:43:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Regular Expressions in VB.NET</title>
		<link>http://www.bluecapstudio.com/blog/2009/11/regular-expressions-in-vb-net/</link>
		<comments>http://www.bluecapstudio.com/blog/2009/11/regular-expressions-in-vb-net/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 17:10:55 +0000</pubDate>
		<dc:creator>Brandon</dc:creator>
				<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.bluecapstudio.com/blog/?p=71</guid>
		<description><![CDATA[The usage of regular expressions can be a powerful thing. With it you can prevent invalid input into your applications and ultimately prevent system crashes or prevent security threats. In VB.NET, it is a fairly simple process which I will go over right now.
The first step is to add the regular expression namespace to your [...]]]></description>
			<content:encoded><![CDATA[<p>The usage of regular expressions can be a powerful thing. With it you can prevent invalid input into your applications and ultimately prevent system crashes or prevent security threats. In VB.NET, it is a fairly simple process which I will go over right now.</p>
<p>The first step is to add the regular expression namespace to your project if it is not already present. At the top of the code outside of any class you will want to have the following:</p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;color: #ccc; font: 12px Consolas, Lucida Console, Monaco, monospace;"><span class="kw6">Imports</span> System.<span class="me1">Text</span>.<span class="me1">RegularExpressions</span></pre></div></div>

<p>This namespace tells the compiler that you want to utilize the attributes and methods within System.Text.RegularExpressions. Without it you will not be able to use regular expressions within your code.</p>
<p>The next step is to declare the regular expression and give it an expression of which it will compare with.</p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;color: #ccc; font: 12px Consolas, Lucida Console, Monaco, monospace;"><span class="kw6">Dim</span> regexObj <span class="kw2">As</span> <span class="kw2">New</span> Regex<span class="br0">&#40;</span><span class="st0">&quot;^\d&quot;</span><span class="br0">&#41;</span></pre></div></div>

<p>As shown, you declare a variable as a new regex type and then simply pass it an expression through the parameters. This then creates a new regular expression and stores it in the variable, in this case named regexObj.</p>
<p>That pretty much all there is to it. The regular expression comes with a list of methods in which you can use the expression. For example:</p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;color: #ccc; font: 12px Consolas, Lucida Console, Monaco, monospace;">regexObj.<span class="me1">isMatch</span><span class="br0">&#40;</span>varName<span class="br0">&#41;</span>
regexObj.<span class="me1">Match</span><span class="br0">&#40;</span>varName<span class="br0">&#41;</span>
regexObj.<span class="me1">Matches</span><span class="br0">&#40;</span>varName<span class="br0">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.bluecapstudio.com/blog/2009/11/regular-expressions-in-vb-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
