Regular expression for an ISBN 13

前端 未结 3 701
广开言路
广开言路 2020-12-18 07:12

Hi all I\'m trying all the time to make a regular expression for XML in my .xsd.

This expression should verify an ISBN-13 number but I couldn\'t get further

相关标签:
3条回答
  • 2020-12-18 07:42

    See also ISBN on xFront :

    We have created an XML Schema simpleType definition for ISBNs. This ISBN definition covers all the legal formats of ISBNs world-wide.

    0 讨论(0)
  • 2020-12-18 08:04

    According to http://regexlib.com/REDetails.aspx?regexp_id=1747 the regular expression

    ISBN(-1(?:(0)|3))?:?\x20+(?(1)(?(2)(?:(?=.{13}$)\d{1,5}([ -])\d{1,7}\3\d{1,6}\3(?:\d|x)$)|(?:(?=.{17}$)97(?:8|9)([ -])\d{1,5}\4\d{1,7}\4\d{1,6}\4\d$))|(?(.{13}$)(?:\d{1,5}([ -])\d{1,7}\5\d{1,6}\5(?:\d|x)$)|(?:(?=.{17}$)97(?:8|9)([ -])\d{1,5}\6\d{1,7}\6\d{1,6}\6\d$)))
    

    matches both the old 10 digit ISBNs and the new 13 digit ISBNs.

    You can easily (maybe not very easily) use the part of this regexp that you need.

    0 讨论(0)
  • 2020-12-18 08:04
    ISBN(?:-13)?:?\x20*(?=.{17}$)97(?:8|9)([ -])\d{1,5}\1\d{1,7}\1\d{1,6}\1\d$
    

    Should match:
    ISBN-13: 978-1-4028-9462-6
    ISBN: 978-1-4028-9462-6
    ISBN-13 978-1-4028-9462-6
    ISBN 978-1-4028-9462-6

    0 讨论(0)
提交回复
热议问题