Regular Expressions 101

Community Patterns

Matches ISBN-10 or ISBN-13 in any text (separator can be space or -)

0

Regular Expression
PCRE2 (PHP >=7.3)

/
(ISBN(?:[- ]*1[03])?:* )+?((?=[0-9X]{10}$|(?=(?:[0-9]+[- ]){3})[- 0-9X]{13}|97[89][0-9]{10}|(?=(?:[0-9]+[- ]){4})[- 0-9]{17})(?:97[89][- ]?)?[0-9]{1,5}[- ]?[0-9]+[- ]?[0-9]+[- ]?[0-9X])
/
gm

Description

Matches ISBN-10 or ISBN-13 in any text (separator can be space or -). You still need to use code to compute checksum using the last digit to validate.

Submitted by anonymous - a year ago