HomeRegex LibraryEthereum (ETH) Address Regex
100% Client-Side β€’ 0 B Data Leaves Browser
security

Ethereum (ETH) Address Regex

Validates Ethereum and EVM-compatible (Polygon, Arbitrum, BSC) public account and contract hexadecimal addresses.

Regular Expression Pattern:
/^0x[a-fA-F0-9]{40}$/
Valid Match Example:
0x71C8451C3343244F0080644085429188e7D4d715
Invalid / Non-Match Example:
71C8451C3343244F0080644085429188e7D4d715

Regex Syntax Breakdown & Explanation

  • β€’^0x : Mandatory hexadecimal prefix
  • β€’[a-fA-F0-9]{40}$ : Exactly 40 hexadecimal characters representing 20-byte address hash

Implementation in Popular Languages

JavaScript / TypeScript
const regex = /^0x[a-fA-F0-9]{40}$/;
const isValid = regex.test("0x71C8451C3343244F0080644085429188e7D4d715");
console.log(isValid); // true
Python (re)
import re

pattern = r"^0x[a-fA-F0-9]{40}$"
match = re.match(pattern, "0x71C8451C3343244F0080644085429188e7D4d715")
print(bool(match)) # True
Go (regexp)
package main
import (
  "fmt"
  "regexp"
)

func main() {
  re := regexp.MustCompile(`^0x[a-fA-F0-9]{40}$`)
  fmt.Println(re.MatchString("0x71C8451C3343244F0080644085429188e7D4d715"))
}
Frequently Asked Questions

Frequently Asked Questions

Everything you need to know regarding specifications, syntax, and security best practices.

The regular expression pattern is /^0x[a-fA-F0-9]{40}$/. Validates Ethereum and EVM-compatible (Polygon, Arbitrum, BSC) public account and contract hexadecimal addresses.