Groovy regex filemail

A groovy regex file mail!

Here's a regex pattern that matches a file mail (a file attached to an email):

^From:.*\r\nTo:.*\r\nSubject:.*\r\n\r\n(?<file_name>.*\.([a-zA-Z0-9]+))\r\n(?<file_data>.*)

Let me break it down:

Here's an example of how this regex pattern would match a file mail:

From: [email protected]
To: [email protected]
Subject: File attachment

file.txt
Content-Type: text/plain; charset=UTF-8
Content-Disposition: attachment; filename="file.txt"

This is the file contents...

In this example, the regex pattern would match the following:

Note that this regex pattern assumes that the file mail has a simple format with a single file attachment. If your file mails have a more complex format (e.g., multiple attachments, different content types), you may need to modify the regex pattern accordingly.