100% Client-Side β’ 0 B Data Leaves Browser
security
Bitcoin (BTC) Address Regex
Validates Bitcoin Legacy (P2PKH starting with 1), SegWit P2SH (starting with 3), and Native SegWit (Bech32 starting with bc1) wallet addresses.
Regular Expression Pattern:
/^(?:1[a-km-zA-HJ-NP-Z1-9]{25,34}|3[a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[a-zA-HJ-NP-Z0-9]{25,39})$/
Valid Match Example:
bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq
Invalid / Non-Match Example:
0x71C8451C3343244F00806440
Regex Syntax Breakdown & Explanation
- β’1[...] : Base58Check P2PKH address
- β’3[...] : Base58Check script hash P2SH address
- β’bc1[...] : Native Bech32 SegWit format
Implementation in Popular Languages
JavaScript / TypeScript
const regex = /^(?:1[a-km-zA-HJ-NP-Z1-9]{25,34}|3[a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[a-zA-HJ-NP-Z0-9]{25,39})$/;
const isValid = regex.test("bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq");
console.log(isValid); // truePython (re)
import re
pattern = r"^(?:1[a-km-zA-HJ-NP-Z1-9]{25,34}|3[a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[a-zA-HJ-NP-Z0-9]{25,39})$"
match = re.match(pattern, "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq")
print(bool(match)) # TrueGo (regexp)
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`^(?:1[a-km-zA-HJ-NP-Z1-9]{25,34}|3[a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[a-zA-HJ-NP-Z0-9]{25,39})$`)
fmt.Println(re.MatchString("bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq"))
}Frequently Asked Questions
Frequently Asked Questions
Everything you need to know regarding specifications, syntax, and security best practices.
The regular expression pattern is /^(?:1[a-km-zA-HJ-NP-Z1-9]{25,34}|3[a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[a-zA-HJ-NP-Z0-9]{25,39})$/. Validates Bitcoin Legacy (P2PKH starting with 1), SegWit P2SH (starting with 3), and Native SegWit (Bech32 starting with bc1) wallet addresses.