Regex for AWS Account ID
Regex Pattern
^\d{12}$AWS account ID — exactly 12 digits
Quick Answer
The regex pattern for aws account id is `^\d{12}$`. AWS account ID — exactly 12 digits. This works in JavaScript, Python, Ruby, PHP, Java, and most regex engines that support PCRE syntax.
Test Examples
| Input | Result |
|---|---|
| 123456789012 | ✓ Matches |
| 000000000000 | ✓ Matches |
| 999999999999 | ✓ Matches |
| 12345678901 | ✗ No match |
| 1234567890123 | ✗ No match |
| abcdefghijkl | ✗ No match |
Code Examples
javascript
const regex = /^\d{12}$/;
const isValid = regex.test(value);python
import re
pattern = r'^\d{12}$'
if re.match(pattern, value):
print("valid")ruby
pattern = /^\d{12}$/
if value =~ pattern
puts "valid"
endphp
if (preg_match('/^\d{12}$/', $value)) {
echo "valid";
}java
String pattern = "^\\d{12}$";
boolean isValid = value.matches(pattern);Frequently Asked Questions
Related Regex Patterns
UUID v4
UUID version 4 (randomly generated)
UUID (Any Version)
Any RFC 4122 UUID (versions 1-5)
JWT Token
JSON Web Token (header.payload.signature)
Hex String
Any-length hexadecimal string
Base64 String
Standard base64 encoded string
Alphanumeric Username
Username with letters, digits, underscores (3-16 chars)