<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>UberDemo : RegEx</title><link>http://blogs.msdn.com/uberdemo/archive/tags/RegEx/default.aspx</link><description>Tags: RegEx</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Regular Expression support in Visual Studio 2008</title><link>http://blogs.msdn.com/uberdemo/archive/2009/04/14/regular-expression-support-in-visual-studio-2008.aspx</link><pubDate>Tue, 14 Apr 2009 20:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9548872</guid><dc:creator>uberdemo</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/uberdemo/comments/9548872.aspx</comments><wfw:commentRss>http://blogs.msdn.com/uberdemo/commentrss.aspx?PostID=9548872</wfw:commentRss><description>&lt;P&gt;Since I write a lot of Silverlight and WPF applications, I make heavy use of Visual Studio, and when I work with large XML files it is very time saving to know how to use Visual Studio’s Regular Expressions search support. Every time I use it&amp;nbsp; though I invariably forget how to write RegEx searches, since I use it so seldom. So as the proverb goes: the weakest ink is better than the best memory. Perhaps you may get some use out of it.&lt;/P&gt;
&lt;P&gt;Regular Expression search is not on by default. To turn it on you need to expand the options section in the &lt;STRONG&gt;Find and Replace&lt;/STRONG&gt; dialog. RegEx search cannot be on by default since certain RegEx characters have completely different meaning that the literal characters and so would cause conflict if both were enabled.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/uberdemo/WindowsLiveWriter/RegularExpressionsupportinVisualStudio20_8D3F/SearchReplaceRegExCA1Z6T88_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/uberdemo/WindowsLiveWriter/RegularExpressionsupportinVisualStudio20_8D3F/SearchReplaceRegExCA1Z6T88_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=SearchReplaceRegExCA1Z6T88 border=0 alt=SearchReplaceRegExCA1Z6T88 src="http://blogs.msdn.com/blogfiles/uberdemo/WindowsLiveWriter/RegularExpressionsupportinVisualStudio20_8D3F/SearchReplaceRegExCA1Z6T88_thumb.jpg" mce_src="http://blogs.msdn.com/blogfiles/uberdemo/WindowsLiveWriter/RegularExpressionsupportinVisualStudio20_8D3F/SearchReplaceRegExCA1Z6T88_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;The &lt;STRONG&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/2k3te2cs.aspx" mce_href="http://msdn.microsoft.com/en-us/library/2k3te2cs.aspx"&gt;Complete Character List&lt;/A&gt;&lt;/STRONG&gt; is conveniently linked off the menu shown when clicking the arrows to the right of the find and replace Textboxes. I tend to learn much more quickly by example, and this page does provide *some* examples, so while useful, it doesn’t contain as many as I’d like. So here are two more for now:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;\&amp;lt;xdate\&amp;gt;(.*)&lt;/STRONG&gt; &lt;/P&gt;
&lt;P&gt;Finds and selects the following node to the end of the line: &amp;lt;xdate&amp;gt;11/14/2008&amp;lt;/xdate&amp;gt; 
&lt;P&gt;This is handy if you need to remove or modify an XML node. Note that the angle brackets are escaped with backslashes. The parentheses' group the period which allows any character and the asterisk which signifies zero or more characters before the carriage return. 
&lt;P&gt;&lt;STRONG&gt;\n~((.+)\n)&lt;/STRONG&gt; 
&lt;P&gt;Finds and selects carriage returns that have empty lines following them. This is handy if you want to compact empty vertical space. Essentially the logic is: Find a carriage return, but only one that precedes a line with a blank carriage return. This search will not find a line if it has spaces contained in the empty line, so you would need to modify it.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I only provided two examples, but if you know of any good RegEx resources please provide a link in the comment, or you can tweet me on &lt;A href="http://www.twitter.com/hanshu" mce_href="http://www.twitter.com/hanshu"&gt;twitter&lt;/A&gt;.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9548872" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/uberdemo/archive/tags/XML/default.aspx">XML</category><category domain="http://blogs.msdn.com/uberdemo/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/uberdemo/archive/tags/RegEx/default.aspx">RegEx</category></item></channel></rss>