<?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>dotnet thoughts &#187; Regular Expressions</title>
	<atom:link href="http://www.dotnetthoughts.net/tag/regular-expressions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dotnetthoughts.net</link>
	<description>a dotnet developer&#039;s technical blog</description>
	<lastBuildDate>Wed, 08 Feb 2012 03:18:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Developing simple Windows 7 Gadget &#8211; Part 1</title>
		<link>http://www.dotnetthoughts.net/2010/02/24/developing-simple-windows-7-gadget-part-1/</link>
		<comments>http://www.dotnetthoughts.net/2010/02/24/developing-simple-windows-7-gadget-part-1/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 14:50:19 +0000</pubDate>
		<dc:creator>Anuraj P</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[Gadget]]></category>
		<category><![CDATA[RegEx]]></category>
		<category><![CDATA[Regular Expressions]]></category>
		<category><![CDATA[Sidebar Gadget]]></category>
		<category><![CDATA[Windows Vista]]></category>

		<guid isPermaLink="false">http://www.dotnetthoughts.net/?p=777</guid>
		<description><![CDATA[Gadgets are simple and lightweight applications, which can be developed using HTML, Javascript and CSS. Gadgets can also include Image files. In Windows Vista, we can create Gadgets by zipping the files, and rename the it with .Gadget extension. In &#8230; <a href="http://www.dotnetthoughts.net/2010/02/24/developing-simple-windows-7-gadget-part-1/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Gadgets are simple and lightweight applications, which can be developed using HTML, Javascript and CSS. Gadgets can also include Image files. In Windows Vista, we can create Gadgets by zipping the files, and rename the it with .Gadget extension. In Windows 7 we can create Gadget by creating the .Gadget folder in C:\Program Files\Windows Sidebar\Gadgets\ folder. This folder contains all the default gadgets from Microsoft.</p>
<p><strong>Creating Simple RegEx Tester Gadget</strong></p>
<p>Regular Expressions are complex but efficient technique for processing text. And the RegEx functions are available in Javascript. So I am to creating simple regex tester gadget using Javascript. You can find a simple RegEx Tester using Javascript here : <a href="http://www.regular-expressions.info/javascriptexample.html" target="_blank">http://www.regular-expressions.info/javascriptexample.html</a>.</p>
<p>For creating a Gadget we require a XML Definition file, which contains the details about the Gadget File, Links to Icons, and Copyright information. Here is skeleton a XML Definition file.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;gadget&gt;
&lt;name&gt;RegExTester&lt;/name&gt;
&lt;namespace&gt;dotnetthoughts&lt;/namespace&gt;
&lt;version&gt;1.0.0.0&lt;/version&gt;
&lt;author name=&quot;dotnetthoughts&quot;&gt;
&lt;info url=&quot;http://dotnetthoughts.net&quot; text=&quot;www.dotnetthoughts.net&quot; /&gt;
&lt;logo src=&quot;logo.png&quot; /&gt;
&lt;/author&gt;
&lt;copyright&gt;&amp;#0169; 2010&lt;/copyright&gt;
&lt;description&gt;For Testing Regular Expressions&lt;/description&gt;
&lt;icons&gt;
&lt;icon width=&quot;64&quot; height=&quot;64&quot; src=&quot;icon.png&quot; /&gt;
&lt;/icons&gt;
&lt;hosts&gt;
&lt;host name=&quot;sidebar&quot;&gt;
&lt;base type=&quot;HTML&quot; apiVersion=&quot;1.0.0&quot; src=&quot;RegExTester.html&quot; /&gt;
&lt;permissions&gt;full&lt;/permissions&gt;
&lt;platform minPlatformVersion=&quot;0.3&quot; /&gt;
&lt;/host&gt;
&lt;/hosts&gt;
&lt;/gadget&gt;
</pre>
<p>And the Tags details are</p>
<p>name: Title of your gadget.<br />
version: Version number of your gadget.<br />
author: Your name or your company’s name.<br />
info url: Web site address.<br />
info text: Friendly name for your Web site.<br />
logo src: Name of company’s logo image file.<br />
copyright: Copyright notice.<br />
description: Description of the gadget.<br />
icon src: Name of icon image file for the gadget.<br />
base src: Name of gadget’s main HTML file.</p>
<div id="attachment_780" class="wp-caption alignnone" style="width: 469px"><a href="http://www.dotnetthoughts.net/wp-content/uploads/2010/02/details.png"><img class="size-full wp-image-780" title="Gadget Details." src="http://www.dotnetthoughts.net/wp-content/uploads/2010/02/details.png" alt="Gadget Details." width="459" height="300" /></a><p class="wp-caption-text">Gadget Details.</p></div>
<p>Save this file as Gadget.xml. Next we need to create the RegExTester.html, which is the main file, nothing but simple HTML file with some UI components.</p>
<pre class="brush: xml; title: ; notranslate">

&lt;html&gt;
&lt;head&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;style.css&quot; /&gt;
&lt;script type=&quot;text/vbscript&quot; src=&quot;message.vbs&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;regexcheck.js&quot;&gt;&lt;/script&gt;
&lt;title&gt;RegEx Tester&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;1&quot; cellspacing=&quot;5&quot; bordercolor=&quot;red&quot;&gt;
&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;u&gt;RegEx Tester&lt;/u&gt;&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;label&gt;Regular Expression&lt;/label&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;textarea id=&quot;txtRegExp&quot; cols=&quot;25&quot; rows=&quot;4&quot;&gt;&lt;/textarea&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;label&gt;Subject String&lt;/label&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;textarea id=&quot;txtSubject&quot; cols=&quot;25&quot; rows=&quot;4&quot;&gt;&lt;/textarea&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;button onclick=&quot;javascript:demoMatchClick();&quot;&gt;Test Match&lt;/button&gt;&amp;nbsp;&amp;nbsp;
&lt;button onclick=&quot;javascript:demoShowMatchClick();&quot;&gt;Show Match&lt;/button&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>You may noticed that I have included a message.vbs file, it helps to display alert() boxes from Javascript. I don&#8217;t know why alert and prompt functions are not available in Gadgets. Also we don&#8217;t need to worry about cross platform compatibility issues in Gadgets, we can write anything supported by Microsoft Internet Explorer.</p>
<p>Here is the code of Message.vbs file.</p>
<pre class="brush: vb; title: ; notranslate">
sub alert(prompt)
MsgBox prompt, 48 , &quot;RegEx Tester&quot;
end sub
</pre>
<p>And here is the contents of regexcheck.js file.</p>
<pre class="brush: jscript; title: ; notranslate">
function demoMatchClick() {
var regExCtrl = document.getElementById(&quot;txtRegExp&quot;);
var subjectCtrl = document.getElementById(&quot;txtSubject&quot;);
var re = new RegExp(regExCtrl.value);
if (subjectCtrl.value.match(re)) {
	alert(&quot;Successful match&quot;);
} else {
	alert(&quot;No match&quot;);
}
}
function demoShowMatchClick() {
var regExCtrl = document.getElementById(&quot;txtRegExp&quot;);
var subjectCtrl = document.getElementById(&quot;txtSubject&quot;);
var re = new RegExp(regExCtrl.value);
var m = re.exec(subjectCtrl.value);
if (m == null) {
	alert(&quot;No match&quot;);
} else {
	var s = &quot;Match at position &quot; + m.index + &quot;:\n&quot;;
	for (i = 0; i &lt; m.length; i++) {
		s = s + m[i] + &quot;\n&quot;;
	}
	alert(s);
}
}
</pre>
<p>Also I added a CSS file for styling the components. Also to specify the Height and Width of the Gadget. In Windows Vista, we need to limit the size of the Gadget, because the Gadget can only place in the Sidebar, but in Windows 7 we can place the Gadget anywhere in the desktop. Also I have added icon.png and logo.png files, as specified in the XML definition file.<br />
The current folder structure is like this.</p>
<div id="attachment_781" class="wp-caption alignnone" style="width: 600px"><a href="http://www.dotnetthoughts.net/wp-content/uploads/2010/02/folder_struct.png"><img class="size-full wp-image-781" title="Folder Structure" src="http://www.dotnetthoughts.net/wp-content/uploads/2010/02/folder_struct.png" alt="Folder Structure" width="590" height="166" /></a><p class="wp-caption-text">Folder Structure</p></div>
<p>Now using any compression tool, compress the files, and Rename it as RegExTester.Gadget. Double click on the Gadget file, Windows will ask for a confirmation.</p>
<div id="attachment_779" class="wp-caption alignnone" style="width: 424px"><a href="http://www.dotnetthoughts.net/wp-content/uploads/2010/02/confirm.png"><img class="size-full wp-image-779" title="Gadget install Confirmation" src="http://www.dotnetthoughts.net/wp-content/uploads/2010/02/confirm.png" alt="Gadget install Confirmation" width="414" height="266" /></a><p class="wp-caption-text">Gadget install Confirmation</p></div>
<p>Click Install. It will start the Gadget. Here is the screenshot of RegExTester gadget running on my Windows 7 machine.</p>
<div id="attachment_782" class="wp-caption alignnone" style="width: 240px"><a href="http://www.dotnetthoughts.net/wp-content/uploads/2010/02/RegExTester_Running.png"><img class="size-full wp-image-782" title="RegExTester Running on Windows 7" src="http://www.dotnetthoughts.net/wp-content/uploads/2010/02/RegExTester_Running.png" alt="RegExTester Running on Windows 7" width="230" height="280" /></a><p class="wp-caption-text">RegExTester Running on Windows 7</p></div>
<p>This is an introduction only, I will try to post about Gadget API, Gadget Settings etc in the next post.</p>
<p>Happy Coding <img src='http://www.dotnetthoughts.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="betterrelated"><p><strong>Related content:</strong></p>
<ol><li> <a href="http://www.dotnetthoughts.net/2010/02/24/developing-simple-windows-7-gadget-part-2/" title="Permanent link to Developing simple Windows 7 Gadget &#8211; Part 2">Developing simple Windows 7 Gadget &#8211; Part 2</a>  </li>
<li> <a href="http://www.dotnetthoughts.net/2010/03/09/developing-simple-windows-7-gadget-part-3/" title="Permanent link to Developing simple Windows 7 Gadget &#8211; Part 3">Developing simple Windows 7 Gadget &#8211; Part 3</a>  </li>
<li> <a href="http://www.dotnetthoughts.net/2007/05/17/activex-controls-in-html-files/" title="Permanent link to ActiveX controls in HTML files">ActiveX controls in HTML files</a>  </li>
<li> <a href="http://www.dotnetthoughts.net/2012/01/29/how-to-create-your-own-custom-accelerator-for-internet-explorer/" title="Permanent link to How to create your own custom Accelerator for Internet Explorer">How to create your own custom Accelerator for Internet Explorer</a>  </li>
<li> <a href="http://www.dotnetthoughts.net/2007/05/16/set-timeout-and-clear-timeout-in-javascript/" title="Permanent link to Set timeout and Clear timeout in Javascript">Set timeout and Clear timeout in Javascript</a>  </li>
</ol></div>]]></content:encoded>
			<wfw:commentRss>http://www.dotnetthoughts.net/2010/02/24/developing-simple-windows-7-gadget-part-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to validate email addess in Windows Forms</title>
		<link>http://www.dotnetthoughts.net/2009/03/24/how-to-validate-email-addess-in-windows-forms/</link>
		<comments>http://www.dotnetthoughts.net/2009/03/24/how-to-validate-email-addess-in-windows-forms/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 12:53:02 +0000</pubDate>
		<dc:creator>Anuraj P</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[.Net 3.0 / 3.5]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Email Validation]]></category>
		<category><![CDATA[RegEx]]></category>
		<category><![CDATA[Regular Expressions]]></category>
		<category><![CDATA[Validation]]></category>

		<guid isPermaLink="false">http://anuraj.wordpress.com/2009/03/24/how-to-validate-email-addess-in-windows-forms/</guid>
		<description><![CDATA[Today I want to add validation for email address in a Windows Forms application. I searched google, but didn&#8217;t got any simple solution. Then I tried with ASP.Net regex validation control and took the validation expression from it used in &#8230; <a href="http://www.dotnetthoughts.net/2009/03/24/how-to-validate-email-addess-in-windows-forms/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today I want to add validation for email address in a Windows Forms application. I searched google, but didn&#8217;t got any simple solution. Then I tried with ASP.Net regex validation control and took the validation expression from it used in RegEx class.</p>
<p>Here is code</p>
<pre class="brush: csharp; title: ; notranslate">
static bool IsValidEmail(string Email)
{
Regex regex = new Regex(@&quot;\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*&quot;);
return regex.IsMatch(emailAddress);
}
</pre>
<p>Happy Coding [:)]</p>
<div class="betterrelated none"><p>No related content found.</p></div>]]></content:encoded>
			<wfw:commentRss>http://www.dotnetthoughts.net/2009/03/24/how-to-validate-email-addess-in-windows-forms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Regular expression to remove HTML tags in VB.Net</title>
		<link>http://www.dotnetthoughts.net/2007/04/19/regular-expression-to-remove-html-tags-in-vbnet/</link>
		<comments>http://www.dotnetthoughts.net/2007/04/19/regular-expression-to-remove-html-tags-in-vbnet/#comments</comments>
		<pubDate>Thu, 19 Apr 2007 18:35:36 +0000</pubDate>
		<dc:creator>Anuraj P</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Regular Expressions]]></category>
		<category><![CDATA[VB]]></category>
		<category><![CDATA[VB.Net]]></category>

		<guid isPermaLink="false">http://anuraj.wordpress.com/2007/04/19/regular-expression-to-remove-html-tags-in-vbnet/</guid>
		<description><![CDATA[Some time we may need to strip all the HTML tags from HTML files, like if we are doing some web scrapping. Here is simple Regular expression which will remove all the HTML Tags. No related content found.]]></description>
			<content:encoded><![CDATA[<p>Some time we may need to strip all the HTML tags from HTML files, like if we are doing some web scrapping. Here is simple Regular expression which will remove all the HTML Tags.</p>
<pre class="brush: vb; title: ; notranslate">
Public Sub RemoveHTMLTags(ByVal expression as string) as string
Dim pattern As String = &quot;&lt;(.|\n)*?&gt;;&quot;
Return System.Text.RegularExpressions.Regex.Replace(strHtmlString, pattern, String.Empty).Trim()
End Sub
</pre>
<div class="betterrelated none"><p>No related content found.</p></div>]]></content:encoded>
			<wfw:commentRss>http://www.dotnetthoughts.net/2007/04/19/regular-expression-to-remove-html-tags-in-vbnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

