Is there any validation you can do other than checking the number of digits, and the check digit? Checking the check digit is pretty simple... beyond that... I don't think there's really any way to tell if the ISBN has _actually_ been assigned or not, or even if the prefix has been actually assigned, without access to lookups of assigned prefixes/ISBNs that I don't think are easily or freely available.
What kind of 'exact' matching are you thinking of? As far as extracting ISBN's from a text full of other stuff too... I don't think there's anything you can do except look for 10 or 13 digit strings that are all numbers or all numbers with a trailing X (possibly with some interfixed hyphens in there), and then checking the check digit.
If you're in ruby, I prefer this gem, which can check ISBN check digit as well as convert from 10 to 13.
https://github.com/entangledstate/isbn
________________________________________
From: Code for Libraries [[log in to unmask]] on behalf of Dan Scott [[log in to unmask]]
Sent: Friday, October 21, 2011 3:40 PM
To: [log in to unmask]
Subject: Re: [CODE4LIB] ISBN Regular Expression
On Oct 21, 2011 2:03 PM, "Kozlowski,Brendon" <[log in to unmask]> wrote:
>
> Oh man. I can't believe I didn't think to check Drupal...or GitHub. Thank
you both! The Ruby version is super simple, but I believe for my purposes
(coverted to PHP anyway) it should suffice. The Drupal module's version also
seems to go the route of simple as opposed to exact matching.
Mmm, for PHP, the PEAR Validate_ISPN package
http://pear.php.net/package/Validate_ISPN/ might be an option.
|