<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Windows PowerShell: Extracting Strings Using Regular Expressions</title>
	<atom:link href="http://www.gfi.com/blog/windows-powershell-extracting-strings-using-regular-expressions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gfi.com/blog/windows-powershell-extracting-strings-using-regular-expressions/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=windows-powershell-extracting-strings-using-regular-expressions</link>
	<description>Brought to you by GFI Software</description>
	<lastBuildDate>Fri, 09 Aug 2013 12:13:46 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: srdjan</title>
		<link>http://www.gfi.com/blog/windows-powershell-extracting-strings-using-regular-expressions/comment-page-1/#comment-42561</link>
		<dc:creator>srdjan</dc:creator>
		<pubDate>Thu, 20 Dec 2012 12:36:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.gfi.com/blog/?p=9168#comment-42561</guid>
		<description><![CDATA[Thanks man, very handy tool]]></description>
		<content:encoded><![CDATA[<p>Thanks man, very handy tool</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Zammit Tabona</title>
		<link>http://www.gfi.com/blog/windows-powershell-extracting-strings-using-regular-expressions/comment-page-1/#comment-40706</link>
		<dc:creator>Andrew Zammit Tabona</dc:creator>
		<pubDate>Sat, 17 Nov 2012 19:03:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.gfi.com/blog/?p=9168#comment-40706</guid>
		<description><![CDATA[Hi Bart,

Thanks for your feedback - glad you found this useful.

To search for two strings in one line of text you will need to combine two regular expressions - in your case, one for the IP addresses and one for the date.

You can combine the two regular expressions into one by using the pipe operator (&#124;), as shown in the sample code below:

$input_path = &#039;c:\ps\ip_addresses.txt&#039;
$output_file = &#039;c:\ps\extracted_ip_addresses.txt&#039;
$regex = &#039;\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b&#124;\b\d{1,2}\/\d{1,2}\/\d{4}\b&#039;
select-string -Path $input_path -Pattern $regex -AllMatches &#124; % { $_.Matches } &#124; % { $_.Value } &gt; $output_file

Note: In this example I am using a regular expression to match dates in the XX/XX/YYYY format. This can be changed as necessary depending on your requirements.

Hope this helps!]]></description>
		<content:encoded><![CDATA[<p>Hi Bart,</p>
<p>Thanks for your feedback &#8211; glad you found this useful.</p>
<p>To search for two strings in one line of text you will need to combine two regular expressions &#8211; in your case, one for the IP addresses and one for the date.</p>
<p>You can combine the two regular expressions into one by using the pipe operator (|), as shown in the sample code below:</p>
<p>$input_path = &#8216;c:\ps\ip_addresses.txt&#8217;<br />
$output_file = &#8216;c:\ps\extracted_ip_addresses.txt&#8217;<br />
$regex = &#8216;\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b|\b\d{1,2}\/\d{1,2}\/\d{4}\b&#8217;<br />
select-string -Path $input_path -Pattern $regex -AllMatches | % { $_.Matches } | % { $_.Value } &gt; $output_file</p>
<p>Note: In this example I am using a regular expression to match dates in the XX/XX/YYYY format. This can be changed as necessary depending on your requirements.</p>
<p>Hope this helps!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bart</title>
		<link>http://www.gfi.com/blog/windows-powershell-extracting-strings-using-regular-expressions/comment-page-1/#comment-40540</link>
		<dc:creator>Bart</dc:creator>
		<pubDate>Mon, 12 Nov 2012 11:03:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.gfi.com/blog/?p=9168#comment-40540</guid>
		<description><![CDATA[But working on this further poped up another question:
I have now my IP&#039;s that I was searching. 
But in that same text line in the logging file there is also the date. 
Can you search on two strings in one line of text?]]></description>
		<content:encoded><![CDATA[<p>But working on this further poped up another question:<br />
I have now my IP&#8217;s that I was searching.<br />
But in that same text line in the logging file there is also the date.<br />
Can you search on two strings in one line of text?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bart</title>
		<link>http://www.gfi.com/blog/windows-powershell-extracting-strings-using-regular-expressions/comment-page-1/#comment-40420</link>
		<dc:creator>Bart</dc:creator>
		<pubDate>Thu, 08 Nov 2012 12:26:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.gfi.com/blog/?p=9168#comment-40420</guid>
		<description><![CDATA[Thx ! 
With your push in the correct direction I got what I needed!]]></description>
		<content:encoded><![CDATA[<p>Thx !<br />
With your push in the correct direction I got what I needed!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

 Served from: www.gfi.com @ 2013-08-12 10:05:21 by W3 Total Cache --