Skip to main content
AllDevToolsHub
Back to all patterns

ISBN-13 Validation

Validation

Validates ISBN-13 book identifiers starting with 978 or 979.

/^(?:978|979)-?\d{1,5}-?\d{1,7}-?\d{1,6}-?\d$/

How it works

ISBN-13 is a 13-digit book identifier. It starts with 978 or 979 (the Bookland prefix), followed by group, publisher, title, and check digit components. Hyphens are optional separators. This pattern validates the format but not the check digit.

Test Cases

Should Match

  • 978-0-306-40615-7
  • 9780306406157
  • 979-1-234-56789-0

Should NOT Match

  • 978-0-306-40615
  • 0-306-40615-7
  • 1234567890123

Quick Summary

Validates ISBN-13 format (starts with 978 or 979, 13 digits total, optional hyphens). Does not validate the check digit, implement the ISBN-13 check digit algorithm separately for full validation.

Key Takeaways

Key Takeaways

  • Must start with 978 or 979 (Bookland EAN prefix)
  • 13 digits total (excluding hyphens)
  • Hyphens are optional separators, strip them before digit counting
  • Check digit validation requires the ISBN-13 Luhn-like algorithm, not covered by this regex
Use Cases

When to use it

  • Validating ISBN inputs in book catalog applications
  • Parsing ISBNs from bibliographic data
  • Checking book identifiers before querying the Google Books API
Watch out

Common Mistakes

  • Not validating the check digit, format validation alone is insufficient for ISBNs
  • Confusing ISBN-10 and ISBN-13, ISBN-10 is 10 digits and does not start with 978/979
FAQ

ISBN-13 Validation, Frequently Asked

How do I convert ISBN-10 to ISBN-13?

Prepend 978 to the first 9 digits of the ISBN-10, then recalculate the check digit using the ISBN-13 algorithm.

How do I validate the ISBN-13 check digit?

Multiply alternating digits by 1 and 3, sum them, and check that the result mod 10 equals 0.