help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: count matches in string, not region?


From: Emanuel Berg
Subject: Re: count matches in string, not region?
Date: Wed, 26 Feb 2020 22:22:14 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Tassilo Horn wrote:

> Another way would be
>
>   (string-match-p "^[[:digit:]]\\{13\\}$" isbn)
>
> which returns non-nil iff isbn is a string of
> exactly thirteen digits.

Okay ... another way of doing ...?

Here is an example of an ISBN-10:

  0-13-308504-X

and here is an ISBN-13:

  978-91-0-011493-0

the check digit is the last one (X meaning 10,
and 0, respectively), so actually one only
needs 9 digits in the first case and 12 in
the second, to compute the check digit.

The groupings (...-...-...-...) do mean things
<https://dataswamp.org/~incal/books/isbn.txt>
but not with respect to how the check digit is
computed, so one can just drop dashes and all
chars that aren't digits.

More examples in the old file,
  https://dataswamp.org/~incal/emacs-init/isbn-verify.el

Thanks for the mail tho, I really want to close
the BOOK on this, so fire away all suggestion
you have :)

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]