tkersey/isbn

Exclude false positives from ISBN.from_string

tmaier opened this issue · 1 comments

Given the following strings:

  • fax: +1 213 413 0950.
  • Fax +1 213 413 0950
  • FAX: +1-213-413-0950

ISBN.from_string gets the ISBN number 1-213-413-095
This is actually not an ISBN number

I see two options how to improve the regex:

  1. Filter for "Fax" etc.; Drawback: this is not generic enough
  2. Ensure that there are not more than 13 numbers (+X) directly adjacent to each other.

@tmaier As you said, option 1 doesn't seem to be generic enough but I'd be willing to review a PR for option 2. It might also be interesting to add a validation that confirms what an isbn is.