Skip to content

Instantly share code, notes, and snippets.

Created August 22, 2016 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/bb861e4c6b4dc0dd634c1d62c825dae0 to your computer and use it in GitHub Desktop.
Save anonymous/bb861e4c6b4dc0dd634c1d62c825dae0 to your computer and use it in GitHub Desktop.
Hi All,
Below is a part of a html file.
******************************************************************************
To: amar.helloween@email.com
Subject: AG Sanity Status - Morning Sanity Check On AG Node 1: 08/22/16 06:25
From: Amarnath.Mahato@cgi.com>
Reply-to: Amarnath.mahato@cgi.com
Content-Type: text/html; charset=us-ascii
<html>
....some content
</html>
******************************************************************************
My task is to remove the content starting from To:amar.helloween.... to us-ascii and only keep the <html>....</html>content
Kindly provide a REGEX to remove the above content.
I tried this , but its not working.. even the date in the subject used to change daily. so help me with this.
$regex1 = 'To: amar.helloween@email.com
Subject: AG Sanity Status - Morning Sanity Check On AG Node 1: 08/22/16 06:25
From: Amarnath.Mahato@cgi.com&gt;
Reply-to: Amarnath.mahato@cgi.com
Content-Type: text/html; charset=us-ascii'
$new_html = @()
gc 'D:\Report.html' -raw |
foreach {
if ($_ -match $regex1)
{
$new_html += ($_ -replace $regex1,'')
$new_html | Out-File "D:\Report1.html"
}
else
{ "did not match"}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment