2015-02-03 11 views
0

안녕하세요 나는 그림과 같이 배달되지 않은 보고서가 있습니다. 나는 정규식을 사용하여 이들을 분석하고 싶다.정규식을 사용하여 오류 eml 분할

(<from:.* to:.*>)([\w\W]*) 

내가 어떻게 3 개의 이메일로 나눌 수 있고 세부적인 부분 만 얻을 수 있는지 처음으로 알려줍니다.

..... 
..... 
bhahbhahbhahbhahbhahbhahbhahbhahbhahbhahbhah..... 
Message-Id: <[email protected]> 

    This is the mail gateway at gw.example.com. 
I'm afraid I wasn't able to deliver your message to the following addresses. 
This is a permanent error; I've given up. Sorry it didn't work out. 

<[email protected]>: 
<from:[email protected] to:[email protected]> 123.123.11.22 does not like recipient 
Remote host said: 550-5.1.1 The email account that you tried to reach does not exist. Please try 
550-5.1.1 double-checking the recipient's email address for typos or 
550-5.1.1 unnecessary spaces. Learn more at 
550 5.1.1 http://support.google.com/mail/bin/answer.py?answer=6596 asd123123.123 - gsmtp 
Giving up on 123.123.11.22. 

<[email protected]>: 
<from:[email protected] to:[email protected]> 21.32.54.65 does not like recipient 
Remote host said: 550 Requested action not taken: mailbox unavailable 
Giving up on 21.32.54.65. 

<[email protected]>: 
<from:[email protected] to:[email protected]> <from:[email protected] to:[email protected]> D12.123.12.12 failed after I sent the message. 
Remote host said: 554 delivery error: dd This user doesn't have a ymail.com account ([email protected]) [0] - mta123.mail.ne1.yahoo.com 

--- Below this line is a copy of the message. 

Return-Path: 
bhahbhahbhahbhahbhahbhahbhahbhahbhahbhahbhah..... 
.... 
.... 

예상 출력

:에서 시작

1: "123.123.11.22 does not like recipient\n Remote host said: 550-5.1.1 The email account that you tried to reach does not exist. Please try\n 550-5.1.1 double-checking the recipient's email address for typos or\n 550-5.1.1 unnecessary spaces. Learn more at\n 550 5.1.1 http://support.google.com/mail/bin/answer.py?answer=6596 asd123123.123 - gsmtp\n Giving up on 123.123.11.22.", 
2: '21.32.54.65 does not like recipient\n Remote host said: 550 Requested action not taken: mailbox unavailable\n Giving up on 21.32.54.65.', 
3: "D12.123.12.12 failed after I sent the message.\n Remote host said: 554 delivery error: dd This user doesn't have a ymail.com account ([email protected]) [0] - mta123.mail.ne1.yahoo.com" 
+0

예상되는 출력은 무엇입니까? –

답변

1

받는 사람/(그러나 그들을 캡처하지 않고) 빈 줄에서 입력 한 다음 끝에서 :

<from:.+ to:.+> ((?:.+\n)*) 

당신이있어 lookbehind 시도 할 수 있지만, 나는 그것이 필요하다고 생각하지 않는다.