Also, I don't know OpenBook to know your source data, but don't forget
a lot of publishers have printed ISBNs in different ways over the past
few years. The regex would choke on any hyphens. If users are
copying from printed material, they could type them in. For example,
one of the books near my desk has the ISBN printed like 0-521-61678-6
if this is user input and nothing is striping characters like that
out, it could cause problems.
(I think I've also seen spaces used instead of hyphens, but less
positive about this).
Jon Gorman
On Mon, Oct 24, 2011 at 9:44 AM, Jonathan Rochkind <[log in to unmask]> wrote:
> John: That's not going to work, an ISBN can end in "X" as a check digit,
> which is not [0-9]. You are going to be rejecting valid ISBN's, you have a
> bug.
>
> On 10/24/2011 10:40 AM, John Miedema wrote:
>>
>> 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<[log in to unmask]>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 [log in to unmask] including the entire contents and
>>> subject of the message.
>>> It will be reviewed by staff and acted upon appropriately.
>>>
>>
>>
>
|