Validationflags: g

ISBN-13

Match 13-digit ISBNs starting with 978 or 979, with optional hyphens or spaces.

Try it in RegexPro →

Available in

JavaScript / ECMAScript code

jsJavaScript
const re = new RegExp("\\b97[89][\\- ]?(?:\\d[\\- ]?){9}\\d\\b", "g");
const input = "978-0-306-40615-7";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));

Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).

Pattern

regexengine-agnostic
\b97[89][\- ]?(?:\d[\- ]?){9}\d\b   (flags: g)

Raw source: \b97[89][\- ]?(?:\d[\- ]?){9}\d\b

How it works

The 978 or 979 GS1 prefix anchors the match, followed by nine digits (with optional separators) and a final check digit.

Examples

Input

978-0-306-40615-7

Matches

  • 978-0-306-40615-7

Input

9780306406157

Matches

  • 9780306406157

Common use cases

  • Modern book catalog validation
  • Retail inventory systems
  • Publisher metadata ingestion
  • ISBN format conversion pipelines

Related patterns