Regular Expressions 101

Community Patterns

International Standard Book Number

0

Regular Expression
PCRE2 (PHP >=7.3)

/
^(?:ISBN(?:-13)?:?\ )?(?=[0-9]{13}$|(?=(?:[0-9]+[-\ ]){4})[-\ 0-9]{17}$)97[89][-\ ]?[0-9]{1,5}[-\ ]?[0-9]+[-\ ]?[0-9]+[-\ ]?[0-9]$
/
gm

Description

This pattern checks for the format according to the International ISBN Agency standard e.g. '978-3-16-148410-0'. Source: https://www.oreilly.com/library/view/regular-expressions-cookbook/9781449327453/ch04s13.html. NOTE: it does not validate if it is an actual ISBN number. It only validates the format.

Submitted by Regular Expressions Cookbook, 2nd Edition by Jan Goyvaerts, Steven Levithan - 2 years ago