Regex for ISBN-13
Regex Pattern
^97[89]\d{10}$ISBN-13 — starts with 978 or 979, 13 digits total
Quick Answer
The regex pattern for isbn-13 is `^97[89]\d{10}$`. ISBN-13 — starts with 978 or 979, 13 digits total. This works in JavaScript, Python, Ruby, PHP, Java, and most regex engines that support PCRE syntax.
Test Examples
| Input | Result |
|---|---|
| 9780306406157 | ✓ Matches |
| 9791234567890 | ✓ Matches |
| 9780131103627 | ✓ Matches |
| 9760306406157 | ✗ No match |
| 978030640615 | ✗ No match |
| 97803064061571 | ✗ No match |
Code Examples
javascript
const regex = /^97[89]\d{10}$/;
const isValid = regex.test(value);python
import re
pattern = r'^97[89]\d{10}$'
if re.match(pattern, value):
print("valid")ruby
pattern = /^97[89]\d{10}$/
if value =~ pattern
puts "valid"
endphp
if (preg_match('/^97[89]\d{10}$/', $value)) {
echo "valid";
}java
String pattern = "^97[89]\\d{10}$";
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)