Skip to content

Commit

Permalink
Fix termination term in email parser regex
Browse files Browse the repository at this point in the history
  • Loading branch information
ptmcg committed Feb 13, 2024
1 parent 0f991b7 commit 58a7658
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGES
Expand Up @@ -26,7 +26,7 @@ Version 3.1.2 - in development
- Added unit tests to test for exception message contents, with enhancement to
`pyparsing.testing.assertRaisesParseException` to accept an expected exception message.

- Added example `email_parser.py`, as suggested by John Byrd (#539).
- Added example `email_address_parser.py`, as suggested by John Byrd (#539).

- Some code refactoring to reduce code nesting, PRs submitted by InSync.

Expand Down
6 changes: 3 additions & 3 deletions examples/email_parser.py → examples/email_address_parser.py
@@ -1,5 +1,5 @@
#
# email_parser.py
# email_address_parser.py
#
# email address parser based on RFC 5322 BNF segments
# - see https://datatracker.ietf.org/doc/html/rfc5322#section-3.4.
Expand All @@ -13,9 +13,9 @@

email_address = Regex(
# RFC5322 email address
r"""(?P<account>(?:(?:"[\w\s()<>[\].,;:@"]+")|[!#-'*+\-/-9=?A-Z\^-~.]+))"""
r"""(?P<account>(?:(?:\"[\w\s()<>[\].,;:@"]+\")|[!#-'*+\-/-9=?A-Z\^-~.]+))"""
"@"
r"""(?P<domain>(?:(?:(?!-)[!#-'*+\-/-9=?A-Z\^-~]{1,63}(?<!-)\.)+[A-Za-z0-9]{2,6})|(?:\[[!-Z^-~]+\]))\b"""
r"""(?P<domain>(?:(?:(?!-)[!#-'*+\-/-9=?A-Z\^-~]{1,63}(?<!-)\.)+[A-Za-z0-9]{2,6})|(?:\[[!-Z^-~]+\]))(?:\b|$)"""
).set_name("email address")


Expand Down
2 changes: 1 addition & 1 deletion tests/test_examples.py
Expand Up @@ -59,4 +59,4 @@ def test_stackish(self):
self._run("stackish")

def test_email_parser(self):
self._run("email_parser")
self._run("email_address_parser")

0 comments on commit 58a7658

Please sign in to comment.