Skip to main content

Regular regexes

The goal of this repo is avoid having to look up commonly used regexes, but have them all bundled in a single place. The focus is on identifiers useful in investigations: identity documents, bank and company numbers, payment cards, phones and SIMs, crypto addresses and seed phrases, vehicles, aircraft, ships, containers and parcels, locations, messaging and file-share links, keys and tokens.

Docs License: MIT

Usage

Install the package using pip install regular-regexes

from regular_regexes import rre

rre.email("mail me at jan@test.com or piet@test.be")  # ['jan@test.com', 'piet@test.be']
rre.be.license_plate("car 1-ABC-123")                 # ['1-ABC-123']
rre.be.iban("BE68 5390 0754 7035")                    # [] (checksum fails)

Every function takes a string and returns the list of matched strings.

rre.ios_system_path and rre.android_system_path take a path on the device, as forensic tools report it, and match it when it lies in a folder the OS keeps for itself (read-only, the same on every phone of a version, nothing the user made): iOS's system volume (/System/, /Library/, /Applications/, /Developer/, /usr/, /bin/, /sbin/) and /private/preboot/Cryptexes/; Android's /system/, /system_ext/, /system_root/, /product/, /vendor/, /odm/, /oem/, /apex/, /bin/, /sbin/. Only at the start of the path, case-sensitive: /data/system/... or /private/var/mobile/Library/... (user data) do not match.

rre.ios_system_path("/System/Library/PrivateFrameworks/x.caf")  # ['/System/Library/PrivateFrameworks/x.caf']
rre.android_system_path("/data/system/usagestats/0")            # []

Universal regexes are on rre directly, country specific ones under their two letter country code: be, de, es, fr, gb (United Kingdom), it, lu, nl, pl and ro. National formats overlap (a Belgian 0495 12 34 56 is also a valid Dutch number), so run the countries that fit the case.

Where an identifier has a checksum (IBAN, national number, Luhn, crypto addresses, MRZ, ...) the match is also validated, so random numbers of the right shape are dropped. Phone numbers are checked against libphonenumber's numbering plans (the phonenumbers package, installed along). Numbers whose bare shape is too common to tell apart are only matched next to their keyword, which is part of the match:

rre.nl.bsn("BSN: 999999990, bare 999999990")  # ['BSN: 999999990']

Available regexes

All regexes, their patterns and checksum validators, with search: regexes.upshift.be. The site is generated from the regexes.json files and their descriptions in docs/descriptions/, and Netlify publishes it on every push to main; to preview it locally:

pip install -r docs/requirements.txt
mkdocs serve

Adding regexes

Universal regexes go in regular_regexes/intl/regexes.json. Country specific ones go in regular_regexes/<country code>/regexes.json (e.g. regular_regexes/be/regexes.json). A new country folder is picked up automatically.

A regex can be paired with a checksum validator from regular_regexes/validators.py; matches that fail it are dropped:

"iban": {"regex": "...", "validator": "iban"}

A validator returns whether the match is valid, or the valid part of it as a string (how a seed phrase is cut out of a longer run of words), and never raises. Any other key in the entry is passed on to the validator ("validator": "phone", "regions": "BE", "kind": "mobile"). A data file it needs (like the BIP39 word list) also goes in package_data in setup.cfg.

Tests live in the same layout: tests/<country code>/test_regexes.py and tests/intl/test_regexes.py. Run them with pytest, after pip install -e . (which also installs phonenumbers).

Metadata

Release files for regular-regexes 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for regular-regexes 0.1.1
File Size Uploaded Provenance Actions
regular_regexes-0.1.1.tar.gz 36.1 kB With provenance Details for regular_regexes-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for regular-regexes 0.1.1
File Interpreter ABI Platform Actions
regular_regexes-0.1.1-py3-none-any.whl Python 3 none any Details for regular_regexes-0.1.1-py3-none-any.whl

Total release size: 74.8 kB

Release files / regular_regexes-0.1.1.tar.gz

Download URL regular_regexes-0.1.1.tar.gz
Size 36.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3134beb89af97586dafba4419a5c06a74c48a2e556c126bc9e1d8048eaeffdb9
BLAKE2b-256 checksum
How to use checksums
42c1b561d0e412d0c228bf4d4312af74dcd29803ce1efc7d88cdc003da57c586
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / regular_regexes-0.1.1-py3-none-any.whl

Download URL regular_regexes-0.1.1-py3-none-any.whl
Size 38.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bc3b1c68412605a5906c93a9e8b3e31b6dec6b542aff93eef16a33cfcf5386ae
BLAKE2b-256 checksum
How to use checksums
680423b24ad905d80fec4f5186bebcc37c248f7115e2d9d66b688987ab2595ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Security for regular-regexes 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for regular_regexes-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page