<?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>Mike&#039;s Blog &#187; regex</title>
	<atom:link href="http://www.brintech.net/tag/regex/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brintech.net</link>
	<description>Gospel study notes and technical journal</description>
	<lastBuildDate>Sat, 04 Feb 2012 17:01:19 +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>Extract All Regular Expression Results (Copy all regex matches to clipboard)</title>
		<link>http://www.brintech.net/extract-all-regular-expression-results-copy-all-regex-matches-to-clipboard/</link>
		<comments>http://www.brintech.net/extract-all-regular-expression-results-copy-all-regex-matches-to-clipboard/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 20:23:14 +0000</pubDate>
		<dc:creator>mbrinson</dc:creator>
				<category><![CDATA[Technical Journal]]></category>
		<category><![CDATA[Technology Recipes]]></category>
		<category><![CDATA[microsoft word]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[regular expressions]]></category>

		<guid isPermaLink="false">http://www.brintech.net/?p=1345</guid>
		<description><![CDATA[This was difficult information to find.  I searched for a method using Notepad++, Vim for windows, and a few others, but finally found the easy way to do this using &#8211; of all things &#8211; Microsoft Word. I&#8217;ll spare you the details of the other methods I attempted and just give you the detailed answer [...]]]></description>
			<content:encoded><![CDATA[<ol>
<p>This was difficult information to  find.  I searched for a method using  Notepad++, Vim for windows, and a few others, but finally found the easy way  to do this using &#8211; of all things &#8211; Microsoft Word.</p>
<p><br class="spacer_" /></p>
<p>I&#8217;ll spare you the  details of the other methods I attempted and just give you the detailed answer  of how to accomplish this with Microsoft Word.</p>
<p><br class="spacer_" /></p>
<p>So I&#8217;ll use my  scenario as the example for what you might want to use this for.</p>
<p><br class="spacer_" /></p>
<p>I had a bunch of  html code from which I needed to extract every instance of anchor text between  the &lt;a href=&#8221;…&#8221;&gt;&lt;/a&gt; tags.  In this particular case here is how you  accomplish this:</p>
<p><br class="spacer_" /></p>
<li>Paste the html code you are      working on into a new word document.</li>
<p><a href="http://www.brintech.net/wp-content/uploads/2010/06/Step1.png"><img class="alignnone size-large wp-image-1346" title="Step1" src="http://www.brintech.net/wp-content/uploads/2010/06/Step1-1024x528.png" alt="" width="1024" height="528" /></a></p>
<p><br class="spacer_" /></p>
<li>Press ctrl+f to bring up the      &#8220;Find and Replace&#8221; dialog box.</li>
<p><a href="http://www.brintech.net/wp-content/uploads/2010/06/Step2.png"><img class="alignnone size-full wp-image-1347" title="Step2" src="http://www.brintech.net/wp-content/uploads/2010/06/Step2.png" alt="" width="974" height="550" /></a></p>
<p><br class="spacer_" /></p>
<li>In my particular case I used      this code in the &#8220;Find what:&#8221; field. -&gt;      \&#8221;\&gt;(*)\&lt;\/a\&gt;</li>
<p>Your needs will  most likely be different and you will need to research a bit if you&#8217;re  unfamiliar with regular expressions.   Even if you are familiar with regular expressions (as I am) you&#8217;ll  still probably need to do a little research to get the exact expression that  will work for you.  I&#8217;m sure there are  regex gurus out there who dream in regex, but in my case I find that I always  have to spend more time than I would like just coming up with the syntax for  the regular expression that will provide me the results I am looking for.  <a href="http://office.microsoft.com/en-us/help/ha010873051033.aspx">Microsoft  Word regular expressions</a>.</p>
<p><br class="spacer_" /></p>
<li>In the &#8220;Search      Options&#8221; portion on the bottom half of the dialog box you&#8217;ll need to      check the box &#8220;Use wildcards&#8221;.       This is what enables the regular expression functionality of      Microsoft Word.</li>
<p><br class="spacer_" /></p>
<li>Just to get a preview of your      results click on the &#8220;Reading Highlight&#8221; drop-down box and      choose &#8220;Highlight All&#8221;</li>
<p><a href="http://www.brintech.net/wp-content/uploads/2010/06/Step3.png"><img class="alignnone size-full wp-image-1348" title="Step5" src="http://www.brintech.net/wp-content/uploads/2010/06/Step3.png" alt="" width="547" height="385" /></a></p>
<p><br class="spacer_" /></p>
<p>Here are the  results in my scenario (which is exactly what I want… well, not exactly.  I&#8217;d like to just get the text in between the  &lt;a&gt; and &lt;/a&gt; tags, but I don&#8217;t know how to do that in one step.  The only way I know to do it is to include  the &#8220;&gt; and the &lt;/a&gt; at the beginning and end of the regular  expression so that it captures what I&#8217;m looking for):</p>
<p><a href="http://www.brintech.net/wp-content/uploads/2010/06/Step4.png"><img class="alignnone size-full wp-image-1349" title="Step5 Results" src="http://www.brintech.net/wp-content/uploads/2010/06/Step4.png" alt="" width="955" height="509" /></a></p>
<p><br class="spacer_" /></p>
<li>Once you&#8217;ve verified that      you&#8217;re getting the results you want by choosing &#8220;Highlight All&#8221;      to preview it, then you click on &#8220;Find in&#8221; and choose &#8220;Main      Document&#8221;</li>
<p><a href="http://www.brintech.net/wp-content/uploads/2010/06/Step5.png"><img class="alignnone size-full wp-image-1350" title="Step6" src="http://www.brintech.net/wp-content/uploads/2010/06/Step5.png" alt="" width="548" height="308" /></a></p>
<p><br class="spacer_" /></p>
<li>All of your highlighted text      will now actually♦ be selected.  Now      right click on top of any of the selected areas in the document and click      on &#8220;copy&#8221;.</li>
<p><a href="http://www.brintech.net/wp-content/uploads/2010/06/Step6.png"><img class="alignnone size-full wp-image-1351" title="Step7" src="http://www.brintech.net/wp-content/uploads/2010/06/Step6.png" alt="" width="831" height="481" /></a></p>
<p><br class="spacer_" /></p>
<li>Press ctrl+n to create a new      document.</li>
<p><br class="spacer_" /></p>
<li>Press ctrl+v to paste what      you&#8217;ve just copied to the clipboard into your new document.</li>
<p><br class="spacer_" /></p>
<li>Press ctrl+f to bring up the      &#8220;Find and Replace&#8221; dialog box again.  Now click on the &#8220;Replace&#8221;      tab.</li>
<p><a href="http://www.brintech.net/wp-content/uploads/2010/06/Step7.png"><img class="alignnone size-full wp-image-1352" title="Step10" src="http://www.brintech.net/wp-content/uploads/2010/06/Step7.png" alt="" width="831" height="611" /></a></p>
<p><br class="spacer_" /></p>
<li>In the &#8220;Find what:&#8221;      field make sure you still have this code -&gt;      \&#8221;\&gt;(*)\&lt;\/a\&gt;</li>
<p>In the  &#8220;Replace with:&#8221; field put this code -&gt; &#8220;\1&#8243; (without  the quotation marks)</p>
<p>Make sure the  &#8220;Use wildcards&#8221; checkbox is checked and then click &#8220;Replace  All&#8221;</p>
<p><br class="spacer_" /></p>
<li>&#8220;Wallah.  She is clean.&#8221;  (Jacques on &#8220;Finding Nemo&#8221;)</li>
<p><a href="http://www.brintech.net/wp-content/uploads/2010/06/Step8.png"><img class="alignnone size-full wp-image-1353" title="Step12" src="http://www.brintech.net/wp-content/uploads/2010/06/Step8.png" alt="" width="788" height="609" /></a></p>
<p><br class="spacer_" /></p>
<p>Kudos and thanks to  <a href="http://groups.google.com/group/regex/browse_thread/thread/d7db0f6c25477c38?pli=1">Ivaylo  for posting his workaround</a> which led to my finding this solution and  expanding on it here.</p>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.brintech.net/extract-all-regular-expression-results-copy-all-regex-matches-to-clipboard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

