Regex for CVE Identifier
Regex Pattern
^CVE-\d{4}-\d{4,}$Common Vulnerabilities and Exposures (CVE) ID
Quick Answer
The regex pattern for cve identifier is `^CVE-\d{4}-\d{4,}$`. Common Vulnerabilities and Exposures (CVE) ID. This works in JavaScript, Python, Ruby, PHP, Java, and most regex engines that support PCRE syntax.
Test Examples
| Input | Result |
|---|---|
| CVE-2021-44228 | ✓ Matches |
| CVE-2023-12345 | ✓ Matches |
| CVE-2024-0001 | ✓ Matches |
| CVE-2021 | ✗ No match |
| CVE-21-44228 | ✗ No match |
| cve-2021-44228 | ✗ No match |
Code Examples
javascript
const regex = /^CVE-\d{4}-\d{4,}$/;
const isValid = regex.test(value);python
import re
pattern = r'^CVE-\d{4}-\d{4,}$'
if re.match(pattern, value):
print("valid")ruby
pattern = /^CVE-\d{4}-\d{4,}$/
if value =~ pattern
puts "valid"
endphp
if (preg_match('/^CVE-\d{4}-\d{4,}$/', $value)) {
echo "valid";
}java
String pattern = "^CVE-\\d{4}-\\d{4,}$";
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)