![]() |
#16 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,782
Karma: 74203799
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I also figured out how to get ISBNs that use X for a check digit. It even accounts for case sensitivity.
![]() Code:
identifiers:"=isbn:~^\d{9}(\d{1}|(X|x))$" OR identifiers:"=isbn:~^\d{1}(-|\s)\d{3}(-|\s)\d{5}(-|\s)(\d{1}|(X|x))$" |
![]() |
![]() |
![]() |
#17 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,933
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
FWIW \d{1} is redundant. \d is a single DIGIT Also: Your pattern is way to tight for small presses 0-1234567-8-X is valid (check digit is incorrect ![]() 1-2-3456789-0 is valid, and any 8 digit combination in between the language and check |
|
![]() |
![]() |
Advert | |
|
![]() |
#18 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,190
Karma: 1988646
Join Date: Aug 2015
Device: Kindle
|
Another approach that gives you more control:
Note: If you want to remove leading and trailing zeros, modify the stored template as follows: Code:
program:
isbn = select(field('identifiers'),'isbn');
isbn = re(isbn, '[^\d]', '');
isbn = re(isbn, '^0', '');
isbn = re(isbn, '0$', '');
strlen(isbn)
Edit: For people who know python, you can replace the stored template with a custom template function. Edit2: Add modifications suggested by chaley in the post below. Edit3: You can skip the first step of creating a stored template, and directly use the followin search: Code:
template:"program: strlen(re(select(field('identifiers'),'isbn'), '[^\d]', ''))#@#:n:=10" Last edited by capink; 02-09-2021 at 12:58 PM. |
![]() |
![]() |
![]() |
#19 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,358
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
program: isbn = select(field('identifiers'),'isbn'); isbn = re(isbn, '[^\d]', ''); # isbn = re(isbn, '(\d)', '\1,'); # count(isbn,',') strlen(isbn) |
|
![]() |
![]() |
![]() |
#20 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,190
Karma: 1988646
Join Date: Aug 2015
Device: Kindle
|
Definitely better. Was not aware of the strlen function. That was I meant by replacing with python (using len() in custom template function). I will edit my post to include your modifications.
|
![]() |
![]() |
Advert | |
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
ISBN metadata search issue | Iconoclastica | Library Management | 12 | 04-26-2020 09:46 PM |
A search for books with NO ISBN in 'Ids'? | 222fbj | Library Management | 3 | 08-06-2016 11:26 AM |
Troubleshooting Kindle PW only stays connected (USB) for 10s at a time? | MyNameIsMrBurns | Amazon Kindle | 9 | 02-27-2015 01:48 AM |
ISBN Search: use Amazon instead of Worldcat? | klieber | Calibre | 9 | 02-21-2014 08:20 AM |
Search on blank ISBN | tilleydog | Calibre | 2 | 07-05-2010 09:27 PM |