regex pattern · ready to copy
Regex for matching Ethereum addresses
Match 0x-prefixed 40-hex Ethereum addresses (case-insensitive — checksum case ignored at format level).
intermediate
javascript / pcre / python4 use cases
The pattern
0x[a-fA-F0-9]{40}
Test cases
| Input | Result |
|---|---|
| 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 | ✓matches |
| 0x0000000000000000000000000000000000000000 | ✓matches |
| 0xshort | ✗rejects |
| 1A1zP1eP... (Bitcoin) | ✗rejects |
| 0xZZZZ... (non-hex) | ✗rejects |
Edge cases & caveats
EIP-55 mixed-case checksum NOT validated by this regex. ALWAYS run keccak256 checksum check after match. ENS names (`vitalik.eth`) need separate handling.
Common use cases
- chat moderation
- donation address sanity check
- phishing detection
- smart-contract address discovery
Try variations against your data
regexlab is a free in-browser tester with side-by-side match highlighting, group inspector, and named-capture export to JS/Python/PCRE.
Open regexlab
Related
us zip code · sql injection keywords · phone number · mac address