PHP split email with rules

瘦欲@ 提交于 2019-12-08 02:51:41

问题


I have to split an email that is received everyday, with a set of rules. This is an example of the email:

A N K U N F T   11.08.15
*** NEUBUCHUNG ***
 11.08.15  xxx  xxx  X3 2830  14:25   17:50
 18.08.15  xxx  xxx  X3 2831  18:40
 F882129  dsdsaidsaia
 F882129  xxxyxyagydaysd

**«CUT HERE»**


A N K U N F T   18.08.15
*** NEUBUCHUNG ***
 11.08.15  xxx  xxx  X3 2830  14:25   17:50
 18.08.15  xxx  xxx  X3 2831  18:40
 F881554  ZXCXZCXCXZCCXZ
 F881554  xcvcxvcxvcvxc
 F881554  xvcxvcxcvxxvccvxxcv

**«CUT HERE»**


11.08.15  xxx  xxx  X3 2830  14:25   17:50
 18.08.15  xxx  xxx  X3 2831  18:40
 F881605  xczxcdfsfdsdfs
 F881605  zxccxzxzdffdsfds

**«CUT HERE»**

So it basically has to be cut whenever the last F999999 appears ( where 9 can be any number). How can I do this?


回答1:


You could try this, though splitting on \n\n would work as

(?:\sF\d+.*?\n\n)\K(\n)

Split on the capture group.

Regex101



来源:https://stackoverflow.com/questions/32012237/php-split-email-with-rules

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!