<?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>SnippetWare.com</title>
	<atom:link href="http://www.snippetware.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.snippetware.com</link>
	<description>Code snippets library</description>
	<lastBuildDate>Fri, 22 Jan 2010 12:04:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Demonstration of using System.Environment type</title>
		<link>http://www.snippetware.com/2010/01/22/demonstration-of-using-system-environment-type/</link>
		<comments>http://www.snippetware.com/2010/01/22/demonstration-of-using-system-environment-type/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 12:04:11 +0000</pubDate>
		<dc:creator>Zaur</dc:creator>
				<category><![CDATA[System]]></category>

		<guid isPermaLink="false">http://www.snippetware.com/?p=737</guid>
		<description><![CDATA[<p><a href="http://www.snippetware.com/2010/01/22/demonstration-of-using-system-environment-type/">Continue</a></p>]]></description>
			<content:encoded><![CDATA[<p>This example demonstrates the usage of <span style="font-family: courier new,courier,monospace;">System.Environment</span> type:</p>
<pre class="brush: csharp">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Program
{
    class Program
    {
        static int Main(string[] args)
        {

            ShowEnvironmentDetails();
            Console.ReadLine();
            return -1;
        }
        static void ShowEnvironmentDetails()
        {
            // Print out the drives on this pc,
            // OS version and other details.
            foreach (string drive in Environment.GetLogicalDrives())
            Console.WriteLine(&quot;Drive: {0}&quot;, drive);
            Console.WriteLine(&quot;OS: {0}&quot;, Environment.OSVersion);
            Console.WriteLine(&quot;Number of processors: {0}&quot;,Environment.ProcessorCount);
            Console.WriteLine(&quot;.NET Version: {0}&quot;,Environment.Version);
            Console.WriteLine(&quot;User name: {0}&quot;, Environment.UserName);
            Console.WriteLine(&quot;Domain name: {0}&quot;, Environment.UserDomainName);
            Console.WriteLine(&quot;Machine name: {0}&quot;, Environment.MachineName);
            Console.WriteLine(&quot;Current directory: {0}&quot;, Environment.CurrentDirectory);
        }
    }
}
</pre>
<p style="text-align: center;"><img alt="" height="463" src="http://www.snippetware.com/wp-content/uploads/envvar(1).png" width="755" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.snippetware.com/2010/01/22/demonstration-of-using-system-environment-type/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Print command-line arguments</title>
		<link>http://www.snippetware.com/2010/01/22/print-command-line-arguments/</link>
		<comments>http://www.snippetware.com/2010/01/22/print-command-line-arguments/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 09:11:38 +0000</pubDate>
		<dc:creator>Zaur</dc:creator>
				<category><![CDATA[System]]></category>

		<guid isPermaLink="false">http://www.snippetware.com/?p=725</guid>
		<description><![CDATA[<p><a href="http://www.snippetware.com/2010/01/22/print-command-line-arguments/">Continue</a></p>]]></description>
			<content:encoded><![CDATA[<p>This example demonstrates how to print arguments that are passed to a program through a command line:</p>
<p><pre class="brush: csharp">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Program
{
    class Program
    {
        static int Main(string[] args)
        {

            // Process any incoming args using &#039;for&#039; keyword.
            for (int i = 0; i &lt; args.Length; i++)
                Console.WriteLine(&quot;Arg: {0}&quot;, args[i]);

            Console.ReadLine();
            return -1;
        }
    }
}
</pre>
</p>
<p>Compile and run this program from the command line adding any arguments after exe file. For example running:<span style="font-family: lucida sans unicode,lucida grande,sans-serif;"> <span style="font-weight: bold;">A</span><strong>rgsTest.exe -arg1 -arg2 -arg2</strong></span> will produce the following result:</p>
<p style="text-align: center;"><img align="middle" alt="" height="276" src="http://www.snippetware.com/wp-content/uploads/args.png" width="598" /></p>
<p>
<br />
The same as above but using &#8216;foreach&#8217; keyword: </p>
<pre class="brush: csharp">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Program
{
    class Program
    {
        static int Main(string[] args)
        {

            // Get arguments using System.Environment.
            string[] theArgs = Environment.GetCommandLineArgs();
            foreach (string arg in theArgs)
                Console.WriteLine(&quot;Arg: {0}&quot;, arg);

            Console.ReadLine();
            return -1;
        }
    }
}
</pre>
</p>
<p>
<br />
Another method using <span style="font-family: courier new,courier,monospace;">GetCommandLineArgs()</span> method of the <span style="font-family: courier new,courier,monospace;">System.Environment</span> type.<br />
</p>
<pre class="brush: csharp">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Program
{
    class Program
    {
        static int Main(string[] args)
        {

            // Get arguments using System.Environment.
            string[] theArgs = Environment.GetCommandLineArgs();
            foreach (string arg in theArgs)
                Console.WriteLine(&quot;Arg: {0}&quot;, arg);

            Console.ReadLine();
            return -1;
        }
    }
}
</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://www.snippetware.com/2010/01/22/print-command-line-arguments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>T-SQL: Find logical name and physical location of system databases</title>
		<link>http://www.snippetware.com/2009/11/03/t-sql-find-logical-name-and-physical-location-of-system-databases/</link>
		<comments>http://www.snippetware.com/2009/11/03/t-sql-find-logical-name-and-physical-location-of-system-databases/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 14:35:14 +0000</pubDate>
		<dc:creator>Zaur</dc:creator>
				<category><![CDATA[Administrative Tasks]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://www.snippetware.com/2009/11/03/t-sql-find-logical-name-and-physical-location-of-system-databases/</guid>
		<description><![CDATA[<p><a href="http://www.snippetware.com/2009/11/03/t-sql-find-logical-name-and-physical-location-of-system-databases/">Continue</a></p>]]></description>
			<content:encoded><![CDATA[<p>The following T-SQL statements will print the logical name and physical location of system database files:</p>
<p><pre class="brush: sql">
USE master;
GO
SELECT name, physical_name AS CurrentLocation, state_desc
FROM sys.master_files
WHERE database_id = DB_ID(N&#039;master&#039;)

SELECT name, physical_name AS CurrentLocation, state_desc
FROM sys.master_files
WHERE database_id = DB_ID(N&#039;tempdb&#039;)

SELECT name, physical_name AS CurrentLocation, state_desc
FROM sys.master_files
WHERE database_id = DB_ID(N&#039;model&#039;)

SELECT name, physical_name AS CurrentLocation, state_desc
FROM sys.master_files
WHERE database_id = DB_ID(N&#039;msdb&#039;)
</pre>
</p>
<p><strong>Result:</strong></p>
<p><a href="http://www.snippetware.com/wp-content/uploads/2009/11/image.png"><img alt="image" border="0" height="351" src="http://www.snippetware.com/wp-content/uploads/2009/11/image_thumb.png" style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" width="701" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.snippetware.com/2009/11/03/t-sql-find-logical-name-and-physical-location-of-system-databases/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>New Features in SQL Server 2008</title>
		<link>http://www.snippetware.com/2009/10/20/whats-new-in-sql-server-2008/</link>
		<comments>http://www.snippetware.com/2009/10/20/whats-new-in-sql-server-2008/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 12:48:35 +0000</pubDate>
		<dc:creator>Zaur</dc:creator>
				<category><![CDATA[Articles]]></category>

		<guid isPermaLink="false">http://www.snippetware.com/?p=712</guid>
		<description><![CDATA[<p><a href="http://www.snippetware.com/2009/10/20/whats-new-in-sql-server-2008/">Continue</a></p>]]></description>
			<content:encoded><![CDATA[<pre>
SQL SERVER 2008 DATABASE IMPLEMENTATION AND MAINTENANCE
MCTS EXAM: 70-432
===================================================================
Exam Objectives:
	1)  New Features in SQL Server 2008
	2)  Installing SQL Server 2008
	3)  Configuring SQL Server 2008
	4)  Managing Security
	5)  Managing Data Encryption
	6)  Managing High Availability
	7)  Maintaining Your Database
	8 )  ETL Techniques
	9)  Managing Replication
	10) Monitoring and Troubleshooting
	11) SQL Server XML Support
	12) Service Broker
	13) Performance Tuning
	14) Implementing Objects
====================================================================
<span id="more-712"></span>
 	New Features in SQL Server 2008
----------------------------------------
1. Compressed Backups

	- not available for SQL Server 2005 Database

	- can be executed from SSMS or T-SQL code as follows:
	        -------------------------------------------------------------
		BACKUP DATABASE [robby] TO DISK = N'C:\Backup\robby.bak' WITH
		NOFORMAT, NOINIT, NAME = N'robby-Full Database Backup', SKIP,
		NOREWIND, NOUNLOAD, COMPRESSION, STATS = 10
	        -------------------------------------------------------------

	- Copy Only Backup: especially useful for taking â€œone off â€ backups for
	  development or testing â€“the advantage is it doesnâ€™t affect transaction log
	  backups or differential backups. Keep in mind it also cannot serve as a
	  base for differential or transaction log backups when restoring either.
	  The T-SQL procedure to do a Copy Only Backup would look like:
	        ------------------------------------------------------------------------
	  	BACKUP DATABASE [robby] TO DISK = N'C:\Backup\robby.bak' WITH COPY_ONLY,
	 	NOFORMAT, NOINIT, NAME = N'robby-Full Database Backup', SKIP, NOREWIND,
	  	NOUNLOAD, STATS = 10
		GO
	        ------------------------------------------------------------------------

	- Enhabnced Configuration and Management for Audits
	  a. Change Data Capture (CDC)
		Auditing is available using the new Change Data Capture (CDC) feature.
		CDC can be used to capture insertions, updates, and deletes in an SQL
		table in a database and place the changes in another table.
		The following SQL code demonstrates how to configure CDC for auditing of
		a table in a database:
	        ------------------------------------------------------------------------
		--Activate CDC
		EXEC sys.sp_cdc_enable_db_change_data_capture
		--Enable CDC on table
		EXEC sys.sp_cdc_enable_table_change_data_capture @source_schema = 'dbo',
		@source_name = 'myTable', @role_name = 'cdc'
	        ------------------------------------------------------------------------
		To read the data from the CDC table, there are a series of system stored
		procedures and functions available, or you can query the tables directly.
		System stored procedures:
			- sys.sp_cdc_add_ job
			- sys.sp_cdc_generate_wrapper_function
			- sys.sp_cdc_change_ job
			- sys.sp_cdc_get_captured_columns
			- sys.sp_cdc_cleanup_change_table
			- sys.sp_cdc_get_ddl_history
			- sys.sp_cdc_disable_db
			- sys.sp_cdc_help_change_data_capture
			- sys.sp_cdc_disable_table
			- sys.sp_cdc_help_ jobs
			- sys.sp_cdc_drop_ job
			- sys.sp_cdc_scan
			- sys.sp_cdc_enable_db
			- sys.sp_cdc_start_ job
			- sys.sp_cdc_enable_table
			- sys.sp_cdc_stop_ job

		System functions:
			- cdc.fn_cdc_get_all_changes_<capture_instance>
			- sys.fn_cdc_has_column_changed
			- cdc.fn_cdc_get_net_changes_<capture_instance>
			- sys.fn_cdc_increment_lsn
			- sys.fn_cdc_decrement_lsn
			- sys.fn_cdc_is_bit_set
			- sys.fn_cdc_get_column_ordinal
			- sys.fn_cdc_map_lsn_to_time
			- sys.fn_cdc_get_max_lsn
			- sys.fn_cdc_map_time_to_lsn
			- sys.fn_cdc_get_min_lsn

	  b. New Table Value Parameter
		The new table type can be passed to a stored procedure.
		To declare a Table User Defined Type in the database:
	        ------------------------------------------------------------------------
		create type MyTableType as table
		(
			Name varchar(150),
			City varchar(20),
			AddressID int
		)
	        ------------------------------------------------------------------------
		And here's the stored procedure that consumes it:
	        ------------------------------------------------------------------------
		create procedure InsertFriends
		(
			@MyTable MyTableType readonly
		)
		as
			insert
			into Friends (Name, city, AddressID)
			select Name, city, AddressID
			from @MyTable;
		--To fill create and fill the temp table:
		declare @MyBestFriends_temp MyTableType
		insert into @MyBestFriends_temp values ('Debbie', 'Havertown', 2)
		insert into @MyBestFriends_temp values ('Chris', 'Philadelphia', 1)
		insert into @MyBestFriends_temp values ('Tom', 'Garden City', 11)
		insert into @MyBestFriends_temp values ('Greg', 'Lansdowne', 6)
		insert into @MyBestFriends_temp values ('Steve', 'Wilmington', 6)

		--And finally, to execute:
		execute InsertFriends @MyBestFriends_temp
	        ------------------------------------------------------------------------

	  c. FileStream Data Types
		The database engine will store all of the data associated with the column
		in a disk file as opposed to the actual database. In order to use FileStream,
		you must first enable it. This is accomplished via the sp_FILESTREAM_configure
		system stored procedure, or via the GUI in Management Studio under advanced
		settings.
		FileStream has the following limitations:
		+ Database mirroring cannot be configured in databases with FileStream data.
		+ Database snapshots are not supported for FileStream data.
		+ Native encryption is not possible by SQL Server for FileStream data.

	  d. Sparse Column Support
		Sparse columns allow for the optimized storage of null columns.
		Must be enabled only on columns that contain sparse data, otherwise size
		storage requirements will grow.
		Can be enabled both from SSMS and T-SQL:
	        ------------------------------------------------------------------------
		CREATE TABLE dbo.Table_1
		(
			OID int NULL,
			MyValue1 varchar(50) SPARSE NULL
		) ON [PRIMARY]
		GO
	        ------------------------------------------------------------------------

Encryption Enhancements
	Transparent data encryption (TDE) allows you to easily encrypt the contents of
	your database and is designed to provide protection to the entire database.
	With TDE, you can encrypt the contents of your database with no changes to your
	application.

	To enable TDE, you need to first create a master key and a certificate. Once the
	master key and certificate are set up, use the following to enable TDE:
        ------------------------------------------------------------------------
		ALTER DATABASE myDatabase SET ENCRYPTION ON
        ------------------------------------------------------------------------
	Once TDE is enabled, itâ€™s designed to be transparent to the application.

	Key Management and Encryption
	Encryption requires keys to secure the database. These keys must be protected and
	backed up so that in the event the system needs to be recreated, the data will
	still be accessible. An enterprise key management system can be incorporated where
	you use a hardware security module to store the keys in separate hardware.

High Availability
	Imporved Mirroring,
	Hot Add CPU,
	Hot Add Memory,
	Failover clustering enhancements (N/A in Web Edition)

	IMPORTANT: Hot Add CPU and Hot Add Memory, and these are supported only in the
	Enterprise edition of SQL Server 2008.

Performance

	+ Performance Data Management
	 - Performance data management allows you to collect performance-related data from
	   your SQL Servers over time. Performance data management consists of a warehouse
	   database (for storing the results) and the data collector, and collection is
	   usually scheduled to run at specific times.

	+ Resource Governor (smiliar to Query Governor)
	 - Resource Governor helps to manage workload, designed to limit resources available
	   to a proccess. Administrator creates a 'workload group' and a 'resource pool'.
	   Workload Groups - containers that hold user sessions. They are mapped to
	   Resource Pools. User sessions are mapped to Workload Groups based on classifier
	   functions.
	   Classifier functions can be: By IP address, User Name, Application Name, etc.

	+ Freeze Plan
	 - Plan freezing is meant to offer greater predictability when it comes to executing
	   a particular query in SQL Server 2008.

SQL Server 2008 Declarative Management Framework (DMF)

	DMF is a policy-based management system for SQL Server.
	Three main components of DMF are: Policies, Conditions and Facets.

Development Improvements

	+ LINQ Support
	 - This is a programming language that allows to map programming objects to
	   database objects.

	+ MERGE Statement
	 - The MERGE statement performs insert, update, or delete operations on a target
	   table based on the results of a join to a source table.
	   Here is an example of MERGE code:
	   --------------------------------------------------------------------------------
		MERGE MyDatabase.Inventory AS target
			USING (SELECT ProductID, SUM(OrderQty) FROM mySales.Orders AS o
		JOIN mySales.mySalesOrderHeader AS soh
			ON o.mySalesOrderID = soh.mySalesOrderID
			AND soh.OrderDate = @OrderDate
		GROUP BY ProductID) AS source (ProductID, OrderQty)
			ON (target.ProductID = source.ProductID)
		WHEN MATCHED AND target.Quantity - source.OrderQty <= 0
			THEN DELETE
		WHEN MATCHED
			THEN UPDATE SET target.Quantity = target.Quantity - source.OrderQty,
			target.ModifiedDate = GETDATE()
		OUTPUT $action, Inserted.ProductID, Inserted.Quantity, Inserted.ModifiedDate,
		Deleted.ProductID,
		Deleted.Quantity, Deleted.ModifiedDate;
	   --------------------------------------------------------------------------------

	+ Spatial Data Type
	 - Spatial Data Type is used store location-based data.

	+ Analysis Services Improvements

	+ ETL/SSIS Enhancements
	 - Many of the new features carry over to SSIS, like Change Data Capture and
	   the MERGE statement. Another good new feature is being able to script in
	   18 Chapter 1 â€¢ New Features in SQL Server 2008 C# instead of only VB.NET.
	   This will make things a bit easier for those of us who really like C#.

Reporting Services

	+ No Longer Requires IIS
	+ Better Graphing
	+ Export to Word Support

	+ Deprecated Features
		- BACKUP  {DATABASE | LOG} WITH PASSWORD
		- BACKUP  {DATABASE | LOG} WITH MEDIAPASSWORD
		- RESTORE {DATABASE | LOG} â€¦ WITH DBO_ONLY
		- RESTORE {DATABASE | LOG} WITH PASSWORD
		- RESTORE {DATABASE | LOG} WITH MEDIAPASSWORD
		- 80 compatibility level and upgrade from version 80.
		- DATABASEPROPERTY
		- WITH APPEND clause on triggers
		- Default setting of disallow results from triggers option = 0
		- sp_dboption
		- FASTFIRSTROW hint
		- sp_addremotelogin
		- sp_addserver
		- sp_dropremotelogin
		- sp_helpremotelogin
		- sp_remoteoption
		- @@remserver
		- SET REMOTE_PROC_TRANSACTIONS
		- sp_dropalias
		- SET DISABLE_DEF_CNST_CHK
		- SET ROWCOUNT for INSERT, UPDATE, and DELETE statements
		- Use of *= and =*
		- COMPUTE / COMPUTE BY
		- sys.database_principal_aliases
		- sqlmaint Utility
		- The RAISERROR (Format: RAISERROR integer string) syntax is deprecated.

	+ Discontinued Features
		- sp_addalias
		- Registered Servers API
		- DUMP statement
		- LOAD statement
		- BACKUP LOG WITH NO_LOG
		- BACKUP LOG WITH TRUNCATE_ONLY
		- BACKUP TRANSACTION
		- 60, 65, and 70 compatibility levels
		- DBCC CONCURRENCYVIOLATION
		- sp_addgroup
		- sp_changegroup
		- sp_dropgroup
		- sp_helpgroup
		- Northwind and pubs
		- Surface Area Configuration Tool
		- sp_makewebtask
		- sp_dropwebtask
		- sp_runwebtask
		- sp_enumcodepages

Abbreviations:
	DMV	-	Dynamic Management Views (SQL Server 2005)
	AWE	-	Address Windowing Extensions
	ETL	-	extract, transfer, load
	DMF	-	Declarative Management Framework
	CDC	-	Change Data Capture
	TDE	-	Transparent data encryption
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.snippetware.com/2009/10/20/whats-new-in-sql-server-2008/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Matching IP Address using the Regular Expression</title>
		<link>http://www.snippetware.com/2009/10/15/matching-ip-address-using-the-regular-expression-2/</link>
		<comments>http://www.snippetware.com/2009/10/15/matching-ip-address-using-the-regular-expression-2/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 20:13:45 +0000</pubDate>
		<dc:creator>Zaur</dc:creator>
				<category><![CDATA[C#.NET]]></category>

		<guid isPermaLink="false">http://www.snippetware.com/2009/10/15/matching-ip-address-using-the-regular-expression-2/</guid>
		<description><![CDATA[<p><a href="http://www.snippetware.com/2009/10/15/matching-ip-address-using-the-regular-expression-2/">Continue</a></p>]]></description>
			<content:encoded><![CDATA[<p>Author: Zaur Bahramov Description: This example demonstrate the quick and simple way to match correct IP address.</p>
<p><a target="_self" href="http://www.snippetware.com/wp-content/uploads/2009/10/MatchesDemo1.zip">MatchesDemo.zip</a></p>
<p><a href="http://www.snippetware.com/wp-content/uploads/2009/10/ipOK1.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="ipOK" border="0" alt="ipOK" height="167" width="427" src="http://www.snippetware.com/wp-content/uploads/2009/10/ipOK_thumb1.png" /></a></p>
<p><a href="http://www.snippetware.com/wp-content/uploads/2009/10/ipBad1.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="ipBad" border="0" alt="ipBad" height="168" width="427" src="http://www.snippetware.com/wp-content/uploads/2009/10/ipBad_thumb1.png" /></a></p>
<p><pre class="brush: csharp">
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace MatchesDemo
{
    public partial class IPValidate : Form
    {
        public IPValidate()
        {
            InitializeComponent();
        }

        private void btnValidate_Click(object sender, EventArgs e)
        {
            // MessageBox.Show(mtxtIPAddress.Text);

            // create a regex object
            Regex checkIP = new Regex (@&quot;\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b&quot;);

            // create match
            Match matchIP = checkIP.Match(mtxtIPAddress.Text);

            if (checkIP.IsMatch(mtxtIPAddress.Text))
            {
                mtxtIPAddress.ForeColor = Color.Green;
            }
            else
                mtxtIPAddress.ForeColor = Color.Red;
        }
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.snippetware.com/2009/10/15/matching-ip-address-using-the-regular-expression-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Demonstration of IsMatch() method</title>
		<link>http://www.snippetware.com/2009/10/15/demonstration-of-ismatch-method/</link>
		<comments>http://www.snippetware.com/2009/10/15/demonstration-of-ismatch-method/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 19:01:18 +0000</pubDate>
		<dc:creator>Zaur</dc:creator>
				<category><![CDATA[C#.NET]]></category>

		<guid isPermaLink="false">http://www.snippetware.com/?p=694</guid>
		<description><![CDATA[<p><a href="http://www.snippetware.com/2009/10/15/demonstration-of-ismatch-method/">Continue</a></p>]]></description>
			<content:encoded><![CDATA[<p>Author: Zaur Bahramov</p>
<p>Description: This example demonstrates the usage of IsMatch() method in C#.NET</p>
<p>
<pre class="brush: csharp">
 using System;
using System.Text.RegularExpressions;

namespace IsMatchDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(@&quot;This will find a match for the regular expression&#039;[A-Z]\d\d&#039;.&quot;);
            Console.WriteLine(&quot;Enter a test string now.&quot;);

            // create regex to match any alphabetical character, followed by a digit
            Regex myRegex = new Regex(@&quot;[A-Z]\d\d&quot;, RegexOptions.IgnoreCase);

            // create a string variable to store input from user
            string inputString;

            // read input
            inputString = Console.ReadLine();

            // create object variable Match as inheriting from Match class
            Match myMatch = myRegex.Match(inputString);

            string outputString = &quot;The following option(s) are set: &quot;;

            // print selected regex option
            Console.WriteLine(outputString + myRegex.Options.ToString());

            // print string typed by user
            Console.WriteLine(&quot;You entered the string: &#039;&quot; + inputString + &quot;&#039;.&quot;);

            // check wether the match occured
            if (myRegex.IsMatch(inputString))
                Console.WriteLine(&quot;The match &#039;&quot; + myMatch.ToString() + &quot;&#039; was found in the string you entered.&quot;);
            else
            Console.WriteLine(&quot;No match was found.&quot;);

            Console.ReadLine();
        }
    }
}
 </pre>
</p>
<p>Output:<BR><br />
<PRE>
This will find a match for the regular expression&#8217;[A-Z]\d\d&#8217;.
Enter a test string now.
 -&#8221;This is a test text: z75. Is this a match?&#8221;
The following option(s) are set: IgnoreCase
You entered the string: &#8216;This is a test text: z75. Is this a match?&#8217;.
The match &#8216;z75&#8242; was found in the string you entered.
</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://www.snippetware.com/2009/10/15/demonstration-of-ismatch-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>POSIX Regex Flavor</title>
		<link>http://www.snippetware.com/2009/10/15/posix-regex-flavor/</link>
		<comments>http://www.snippetware.com/2009/10/15/posix-regex-flavor/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 11:49:24 +0000</pubDate>
		<dc:creator>Zaur</dc:creator>
				<category><![CDATA[Flavors]]></category>

		<guid isPermaLink="false">http://www.snippetware.com/?p=692</guid>
		<description><![CDATA[<p><a href="http://www.snippetware.com/2009/10/15/posix-regex-flavor/">Continue</a></p>]]></description>
			<content:encoded><![CDATA[<pre>
POSIX
=======================================================
[:upper:]		Upper case letters
[:lower:]		Lower case letters
[:alpha:]		All letters
[:alnum:]		Digits and letters
[:digit:]		Digits
[:xdigit:]		Hexadecimal digits
[:punct:]		Punctuation
[:blank:]		Space and tab
[:space:]		Blank characters
[:cntrl:]		Control characters
[:graph:]		Printed characters and spaces
[:word:]		Digits, letters and underscore
--------------------------------------------------------
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.snippetware.com/2009/10/15/posix-regex-flavor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enumerate Attributes of an XML Node</title>
		<link>http://www.snippetware.com/2009/10/15/enumerate-attributes-of-an-xml-node/</link>
		<comments>http://www.snippetware.com/2009/10/15/enumerate-attributes-of-an-xml-node/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 08:41:49 +0000</pubDate>
		<dc:creator>Zaur</dc:creator>
				<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.snippetware.com/?p=690</guid>
		<description><![CDATA[<p><a href="http://www.snippetware.com/2009/10/15/enumerate-attributes-of-an-xml-node/">Continue</a></p>]]></description>
			<content:encoded><![CDATA[<p>Author: Microsoft&nbsp;</p>
<pre class="brush: vb.net">
&#039; ----------------------------------------
&#039;  Required Imports :
&#039;
&#039;  System.Xml
&#039; ----------------------------------------

For Each attribute As XmlAttribute In node.Attributes

Next
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.snippetware.com/2009/10/15/enumerate-attributes-of-an-xml-node/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add an Element to a XML Document</title>
		<link>http://www.snippetware.com/2009/10/15/add-an-element-to-a-xml-document/</link>
		<comments>http://www.snippetware.com/2009/10/15/add-an-element-to-a-xml-document/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 08:37:33 +0000</pubDate>
		<dc:creator>Zaur</dc:creator>
				<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.snippetware.com/?p=688</guid>
		<description><![CDATA[<p><a href="http://www.snippetware.com/2009/10/15/add-an-element-to-a-xml-document/">Continue</a></p>]]></description>
			<content:encoded><![CDATA[<p>Author: Microsoft<br />
Adds a new element to an XML document instance.</p>
<pre class="brush: vb.net">
&#039; ----------------------------------------
&#039;  Required Imports :
&#039;
&#039;  System.Xml
&#039; ----------------------------------------

Dim newElement As XmlNode
newElement = xmlDoc.CreateElement(&quot;Keyword&quot;)
newElement.InnerText = &quot;Value&quot;
xmlDoc.AppendChild(newElement)
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.snippetware.com/2009/10/15/add-an-element-to-a-xml-document/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Regular Expressions in Microsoft Word</title>
		<link>http://www.snippetware.com/2009/10/15/using-regular-expressions-in-microsoft-word/</link>
		<comments>http://www.snippetware.com/2009/10/15/using-regular-expressions-in-microsoft-word/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 08:00:27 +0000</pubDate>
		<dc:creator>Zaur</dc:creator>
				<category><![CDATA[Microsoft Word]]></category>

		<guid isPermaLink="false">http://www.snippetware.com/?p=684</guid>
		<description><![CDATA[<p><a href="http://www.snippetware.com/2009/10/15/using-regular-expressions-in-microsoft-word/">Continue</a></p>]]></description>
			<content:encoded><![CDATA[<pre>
In Microsoft Office Word you have to use Wild card to search with regular expressions.
These are not exactly the same as in other regex flavours.
To use regular expressions (wildcards) in Word 2003, simply select the  Edit menu;
then select Find. Alternatively, you can use the equivalent keyboard shortcut Ctrl+F.
The Find and Replace dialog box opens. Check the use WildCards check box.

Metacharacter		Description
=============		========================================================
?			Nonstandard usage (in Word, it is not a quantifier).
			Matches a single character. Broadly equivalent to
			the dot metacharacter (.) in standard syntax.

*			Nonstandard usage. Matches zero or more characters.
			Broadly equivalent to .* in standard syntax.

&lt; 			Matches the position between a nonalphabetic character
			and a following alphabetic character. Effectively, a
			beginning-of-word position metacharacter.

> 			Matches the position between an alphabetic character
			and a following nonalphabetic character. Effectively,
			an end-of-word position metacharacter.

[...] 			Character class delimiters.

! 			Used in character classes as the character class negation
			metacharacter.

{n,m} 			Quantifier syntax.

@ 			Quantifier. Nonstandard syntax, to match one or more
			occurrences of the preceding character or group. Equivalent
			to the + metacharacter in standard syntax.

			EXAMPLES
============================================================================================
Problem: 		Match dates in various country formats
Sample Text:		2005-12-25
			12/11/2003
			01.25.2006
			03-18-2007
			07-19-2004
			2006/09/18
RegEx 1:		([0-9]{2})[./-]([0-9]{2})[./-]([0-9]{4})
Replacement 1:		\3-\1-\2
Explanation:		If all has gone well, the pattern should match the dates that are
			in U.S. format but not those that are already in international date
			format. We have assumed that all entries are valid dates. The
			pattern shown would also match nonsense character sequences such as
			44/12/5432.
--------------------------------------------------------------------------------------------

NOTE: Period character in Microsoft Word must be enclosed in square bracket, like this [.]
Sample: To create a capturing group containing a period, use: ([.])

EXAMPLE:
Sometimes you can omit a space character between period in the end of sentence and the new sentence.
In such cases you end up with something like this: &quot;He goes to work.He takes a taxi.&quot;
To match lower-case alphabetic character, followed by period and followed by upper-case character
the following RegEx can be successfully applied: [a-z][.][A-Z]. If you need to make a replacement
you should use it within a capturing groups, like this: ([a-z][.])([A-Z])
Replacement string will be: \1 \2 (note the space between \1 and \2!)
</pre>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.snippetware.com/2009/10/15/using-regular-expressions-in-microsoft-word/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

