Re: ISBN Regular Expression

From: John Miedema <john.miedema_at_nyob>
Date: Mon, 24 Oct 2011 10:40:02 -0400
To: CODE4LIB_at_LISTSERV.ND.EDU
Here's a php function I use in OpenBook to test if a user has entered a 10
or 13 digit ISBN.

//test if 10 or 13 digits ISBN
function openbook_utilities_validISBN($testisbn) {
return (ereg ("([0-9]{10})", $testisbn, $regs) || ereg ("([0-9]{13})",
$testisbn, $regs));
}



On Fri, Oct 21, 2011 at 1:44 PM, Kozlowski,Brendon <bkozlowski_at_sals.edu>wrote:

> Hi all.
>
>
>
> I'm somewhat surprised that I've never had to validate an ISBN manually up
> until now. I suppose that's a testiment to all of the software out there.
>
>
>
> However, I now find that I need to validate both the 10-digit and 13-digit
> ISBNs. I realize there's also a check digit and a REGEX cannot check this
> value - one step at a time. Right now I just want to work on the REGEX.
>
>
>
> Does anyone know the exact specifications of both forms of an ISBN? The
> ISBN organization's website didn't seem to be overly clear to me.
> Alternatively, if anyone has a full working regular expression for this
> purpose I would definitely not mind if they'd be willing to share.
>
>
>
> The only thing I'm doing which is abnormal is that I am not requiring the
> hyphenation or spaces between numbers since some of this data will be coming
> from a system, and some will be coming from human input.
>
>
>
>
> Brendon Kozlowski
> Web Administrator
> Saratoga Springs Public Library
> 49 Henry Street
> Saratoga Springs, NY, 12866
> [518] 584-7860 x217
>
> Please consider the environment before printing this message.
>
> To report this message as spam, offensive, or if you feel you have received
> this in error,
> please send e-mail to abuse_at_sals.edu including the entire contents and
> subject of the message.
> It will be reviewed by staff and acted upon appropriately.
>



-- 
John Miedema - john.miedema_at_gmail.com - h: 613-366-7960 - m: 819-208-0144 -
http://johnmiedema.ca - @johnmiedema
Received on Mon Oct 24 2011 - 10:41:42 EDT