Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save enthus1ast/81f67b21a6bec8e9646b6673636d8651 to your computer and use it in GitHub Desktop.
Save enthus1ast/81f67b21a6bec8e9646b6673636d8651 to your computer and use it in GitHub Desktop.
peg is not matching the whole header.
# Extract of the testfile:
Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00000000 44 61 74 65 3A 20 46 72 69 2C 20 31 39 20 4D 61 Date: Fri, 19 Ma
00000010 79 20 32 30 30 30 20 31 30 3A 31 38 3A 30 33 20 y 2000 10:18:03
00000020 2D 30 34 30 30 20 28 45 44 54 29 0D 0A 46 72 6F -0400 (EDT)..Fro
00000030 6D 3A 20 44 6F 75 67 20 53 61 75 64 65 72 20 3C m: Doug Sauder <
00000040 64 6F 75 67 40 70 65 6E 67 75 69 6E 2E 65 78 61 [email protected]
00000050 6D 70 6C 65 2E 63 6F 6D 3E 0D 0A 54 6F 3A 20 3D mple.com>..To: =
00000060 3F 69 73 6F 2D 38 38 35 39 2D 31 3F 51 3F 4A 3D ?iso-8859-1?Q?J=
00000070 46 43 72 67 65 6E 5F 53 63 68 6D 3D 46 43 72 67 FCrgen_Schm=FCrg
00000080 65 6E 3F 3D 20 3C 73 63 68 6D 75 65 72 67 65 6E en?= <schmuergen
00000090 40 65 78 61 6D 70 6C 65 2E 63 6F 6D 3E 0D 0A 53 @example.com>..S
000000A0 75 62 6A 65 63 74 3A 20 3D 3F 69 73 6F 2D 38 38 ubject: =?iso-88
000000B0 35 39 2D 31 3F 51 3F 44 69 65 5F 48 61 73 65 6E 59-1?Q?Die_Hasen
000000C0 5F 75 6E 64 5F 64 69 65 5F 46 72 3D 46 36 73 63 _und_die_Fr=F6sc
000000D0 68 65 3F 3D 0D 0A 4D 65 73 73 61 67 65 2D 49 44 he?=..Message-ID
000000E0 3A 20 3C 50 69 6E 65 2E 4C 4E 58 2E 34 2E 32 31 : <Pine.LNX.4.21
# The peg looks like this
# this should match everything except \n\n (i think)
emailstr.find(peg"{([^\13] [^\10] [^\13] [^\10])+}",matches)
# matches is:
@[Date: Fri, 19 May 2000 10:18:03 -0400 (EDT)
From: Doug Sauder <[email protected]>
To: =?iso-8859-1?Q?J=FCrgen_Schm=FCrgen?= <[email protected]>
Subject: =?iso-8859-1?Q?Die_Hasen_und_die_Fr=F6sche?=, , ]
any idea why it stops matching at the subject line?
I would expect it matching the whole header.
=================================================================================
Date: Fri, 19 May 2000 10:18:03 -0400 (EDT)
From: Doug Sauder <[email protected]>
To: =?iso-8859-1?Q?J=FCrgen_Schm=FCrgen?= <[email protected]>
Subject: =?iso-8859-1?Q?Die_Hasen_und_die_Fr=F6sche?=
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=iso-8859-1
Content-Transfer-Encoding: QUOTED-PRINTABLE
Die Hasen und die Fr=F6sche
Die Hasen klagten einst =FCber ihre mi=DFliche Lage; "wir leben", sprach ei=
n Redner, "in steter Furcht vor Menschen und Tieren, eine Beute der Hunde, =
der Adler, ja fast aller Raubtiere! Unsere stete Angst ist =E4rger als der =
Tod selbst. Auf, la=DFt uns ein f=FCr allemal sterben."=20
=================================================================================
@enthus1ast
Copy link
Author

It should match from
"Date" to "QUOTED-PRINTABLE"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment