Miguel Sousa
Miguel Sousa

Reputation: 55

PHP split email with rules

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?

Upvotes: 2

Views: 119

Answers (1)

d0nut
d0nut

Reputation: 2834

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

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

Split on the capture group.

Regex101

Upvotes: 2

Related Questions