Skip to content

Instantly share code, notes, and snippets.

@chauminhvu
chauminhvu / remove_email_signature.py
Last active November 28, 2025 20:11
Python utility to strip email signatures and extract body text. Supports standard delimiters and closings in EN, FR, DE, IT, NL, & LB.
import re
def remove_signature(text: str) -> tuple[str, str]:
"""
Splits email content into body text and signature, supporting multiple European languages.
Detects common signature delimiters, closing salutations, and Markdown-specific patterns.
Intentional Behaviors:
- Preserves reply headers (e.g., "On ... wrote:") within the body text when no explicit signature is found.