Generic API Key
Match generic long alphanumeric tokens (32+ chars) typical of API keys and access tokens.
Try it in RegexPro →Available in
JavaScript / ECMAScript code
const re = new RegExp("\\b[A-Za-z0-9_\\-]{32,}\\b", "g");
const input = "sk_test_abcdef0123456789abcdef0123456789abcd";
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[A-Za-z0-9_\-]{32,}\b")
input_text = "sk_test_abcdef0123456789abcdef0123456789abcd"
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[A-Za-z0-9_\-]{32,}\b`)
input := `sk_test_abcdef0123456789abcdef0123456789abcd`
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[A-Za-z0-9_\-]{32,}\b (flags: g)Raw source: \b[A-Za-z0-9_\-]{32,}\b
How it works
Examples
Input
sk_test_abcdef0123456789abcdef0123456789abcdMatches
sk_test_abcdef0123456789abcdef0123456789abcd
Input
shortNo match
—Common use cases
- •Secret scanning in git repos
- •DLP for accidental commits
- •Log redaction pipelines
- •Security audit of config files
Related patterns
Stripe API Key
SecurityMatch Stripe API keys: secret (sk_), publishable (pk_), or restricted (rk_), in test or live mode.
AWS Access Key ID
SecurityMatch AWS access key IDs (both long-term AKIA and temporary ASIA prefixes).
SSH Public Key
SecurityMatch SSH public keys in OpenSSH `authorized_keys` format, including the optional comment field.
GitHub Personal Access Token
SecurityMatch GitHub Personal Access Tokens (classic + fine-grained) and OAuth tokens by their `ghX_` prefix.