2012-08-22 2 views
0

자동 전자 메일 응답을 만들고 있지만 응답에 원래 전자 메일을 표시하고 싶지 않습니다. 전자 메일에는 그들이 위에 응답해야하는 줄이 있습니다. 그러나 이메일 프로그램에는 "2012 년 8 월 21 일 오후 11시 30 분에 다음과 같이 행이 추가됩니다.항목 앞 줄에 preg_split

이 코드를 사용하여 응답을 두 부분으로 나눕니다. 그것은 단지 올바르게 작동하지 않습니다. 이 분할의

$parts = preg_split('/([\r|\n].+[\r|\n]>[\r|\n])?(>)?--- ABOVE THIS LINE ---/',$in->body); 

이메일 몸은 내가 ---이 선 위에 --- 위의 내용으로 줄에서 분할 비트를 수행 할 작업을

test from user back again 

On Wed, Aug 22, 2012 at 9:55 AM, Support <[email protected]> wrote: 

> --- ABOVE THIS LINE --- 
> 
> Support Ticket 

입니다. 다른 말로하면 "On Wed, Aug 22 ..."줄을 제거하고 싶습니다. 나는 모든 전자 메일 프로그램이이 줄을 입력하는 것은 아니라고 가정합니다. 이 예제에서 전자 메일 프로그램은 실제로 빈 줄을 추가하고 있습니다.

답변

0

여기 있습니다.

/^.*wrote:(?s).* --- ABOVE THIS LINE ---/im 

과 설명 :

# ^.*wrote:(?s).* --- ABOVE THIS LINE --- 
# 
# Options: case insensitive;^and $ match at line breaks 
# 
# Assert position at the beginning of a line (at beginning of the string or after a line break character) «^» 
# Match any single character that is not a line break character «.*» 
# Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*» 
# Match the characters “wrote:” literally «wrote:» 
# Match the remainder of the regex with the options: dot matches newline (s) «(?s)» 
# Match any single character «.*» 
# Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*» 
# Match the characters “ --- ABOVE THIS LINE ---” literally « --- ABOVE THIS LINE ---»