Code:
Hello All,

I am trying to fetch some information from the email header. I am piping the mail to my script and want to fetch the particular content from the header but I am having difficulties to fetch it.

My seacrh string is as given below.
===========================
my $test = '(From) (\S*'at'*\S*)(\s*)(\S*\s*\S*\s*\S*\s*\S*\s*\S*)(s*)(.*)(\s*)(id)(\s*)(\w\w\w\w\w\w-\w\w\w\w\w\w-\w\w*)(\s*)(for email'at'domain_name.com)(\s*)(;)(\s*)(\S*\s*\S*\s*\S*\s*\S*)(\s*)(\d\d:\d\d:\d\d)(.*)(\s*)(Subject:)(\s*)(.*)(\s*)(From:|Message-Id:)(\s*)(.*)';
============================

It is working well if mail header does not have any one value in it out of (From:|Message-Id:) but if the mail header have both of them then it is printing the Subject line along with the Message_Id or From: which ever is there in the header first.
For example I am getting the Subject line as below :
Subject=>test from test email account  Message-Id: <E1Ok1yC-0006AT-Co'at'domain_name.com>

I want to select only subject filed. Is there any way to strip both of the string (From:,Message-Id ) using the regex.

I also want to know if there is any way to replace new line character with string in a multi-line string.

I tried to replace with it space and it is working but if I am trying it with string such as AAAA or BBBB my script is not executing itself. 

And how to match the \t character and parse the string if more than two \t char found . I want to select the word which is followed by more than two \t character. 

Thank you
Reply