Bitcoin Address
Match Bitcoin addresses in legacy (P2PKH/P2SH) and SegWit Bech32 (bc1) formats.
Try it in RegexPro →Available in
JavaScript / ECMAScript code
const re = new RegExp("\\b(?:[13][a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[a-zA-HJ-NP-Z0-9]{25,62})\\b", "g");
const input = "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).
Python (re) code
import re
pattern = re.compile(r"\b(?:[13][a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[a-zA-HJ-NP-Z0-9]{25,62})\b")
input_text = "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
for m in pattern.finditer(input_text):
print(m.group(0))Stdlib `re` module — no third-party dependency. Works on Python 3.6+.
Go (RE2) code
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`\b(?:[13][a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[a-zA-HJ-NP-Z0-9]{25,62})\b`)
input := `1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa`
for _, match := range re.FindAllString(input, -1) {
fmt.Println(match)
}
}Uses `regexp.MustCompile` (panics on bad patterns at startup) and `FindAllString` for all matches.
Pattern
\b(?:[13][a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[a-zA-HJ-NP-Z0-9]{25,62})\b (flags: g)Raw source: \b(?:[13][a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[a-zA-HJ-NP-Z0-9]{25,62})\b
How it works
Examples
Input
1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNaMatches
1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
Input
3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLyMatches
3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy
Common use cases
- •Wallet address validation
- •Forensic / compliance scans
- •Donation link generation
- •On-chain analytics preprocessing
Related patterns
AWS Access Key ID
SecurityMatch AWS access key IDs (both long-term AKIA and temporary ASIA prefixes).
bcrypt Password Hash
SecurityMatch bcrypt password hashes in their canonical $2a$/$2b$/$2y$ prefixed format.
Bearer Token (Authorization Header)
SecurityMatch Bearer token values from HTTP Authorization headers, capturing the raw token string.
Generic API Key
SecurityMatch generic long alphanumeric tokens (32+ chars) typical of API keys and access tokens.