Generic API Key in JS
Match generic long alphanumeric tokens (32+ chars) typical of API keys and access tokens.
Try it in the JS tester →Pattern
regexJS
\b[A-Za-z0-9_\-]{32,}\b (flags: g)JavaScript / ECMAScript code
jsJavaScript
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).
How the pattern works
Word-bounded sequence of 32 or more letters, digits, underscores, or hyphens. Broad by design — pair with context (e.g. api_key=) to reduce false positives.
Examples
Input
sk_test_abcdef0123456789abcdef0123456789abcdMatches
sk_test_abcdef0123456789abcdef0123456789abcd
Input
shortNo match
—