AWS Access Key ID in JS
Match AWS access key IDs (both long-term AKIA and temporary ASIA prefixes).
Try it in the JS tester →Pattern
regexJS
\b(?:AKIA|ASIA)[0-9A-Z]{16}\b (flags: g)JavaScript / ECMAScript code
jsJavaScript
const re = new RegExp("\\b(?:AKIA|ASIA)[0-9A-Z]{16}\\b", "g");
const input = "AKIAIOSFODNN7EXAMPLE";
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
Starts with AKIA (long-term user key) or ASIA (short-term STS session key), followed by exactly 16 uppercase alphanumeric characters. Word boundaries prevent partial matches.
Examples
Input
AKIAIOSFODNN7EXAMPLEMatches
AKIAIOSFODNN7EXAMPLE
Input
ASIAIOSFODNN7EXAMPLEMatches
ASIAIOSFODNN7EXAMPLE
Input
not a keyNo match
—