Identifiers
Python Package Name (PEP 508)
Validate Python distribution package names per PEP 508: letters, digits, dots, underscores, hyphens.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
^[A-Za-z0-9](?:[A-Za-z0-9._\-]*[A-Za-z0-9])?$Raw source: ^[A-Za-z0-9](?:[A-Za-z0-9._\-]*[A-Za-z0-9])?$
How it works
Starts and ends with alphanumeric. Allows `_`, `.`, `-` in the middle. The single-char form (just an alphanumeric) is also valid. PEP 508 / PEP 503 normalize all of `_`, `.`, `-` to a single `-` for matching, but the underlying name on PyPI may use any.
Examples
Input
requestsMatches
requests
Input
django-rest-frameworkMatches
django-rest-framework
Input
_invalidNo match
—Common use cases
- •pip / poetry / uv config validation
- •PyPI package-name availability checks
- •Migration tooling between requirements formats
- •Auto-completion in package managers
Related patterns
npm Package Name
IdentifiersValidate npm package names including scoped packages (@org/package), per the npm naming spec.
AWS S3 Bucket Name
IdentifiersValidate AWS S3 bucket names per the standard naming rules: 3–63 chars, lowercase, alphanumeric + dots + hyphens.
Kubernetes Pod Name (RFC 1123)
IdentifiersValidate Kubernetes pod names per the RFC 1123 DNS label rules — lowercase, ≤63 chars, no leading/trailing hyphen.
AWS ARN (Amazon Resource Name)
IdentifiersMatch AWS ARNs (Amazon Resource Names) across commercial, China, and GovCloud partitions.