Regex for ISBN-10
Regex Pattern
^\d{9}[\dX]$ISBN-10 — 9 digits plus a check digit (0-9 or X)
Quick Answer
The regex pattern for isbn-10 is `^\d{9}[\dX]$`. ISBN-10 — 9 digits plus a check digit (0-9 or X). This works in JavaScript, Python, Ruby, PHP, Java, and most regex engines that support PCRE syntax.
Test Examples
| Input | Result |
|---|---|
| 0306406152 | ✓ Matches |
| 048665088X | ✓ Matches |
| 0131103628 | ✓ Matches |
| 03064061521 | ✗ No match |
| 030640615 | ✗ No match |
| ABCDEFGHIJ | ✗ No match |
Code Examples
javascript
const regex = /^\d{9}[\dX]$/;
const isValid = regex.test(value);python
import re
pattern = r'^\d{9}[\dX]$'
if re.match(pattern, value):
print("valid")ruby
pattern = /^\d{9}[\dX]$/
if value =~ pattern
puts "valid"
endphp
if (preg_match('/^\d{9}[\dX]$/', $value)) {
echo "valid";
}java
String pattern = "^\\d{9}[\\dX]$";
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)