Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 02-09-2021, 04:52 AM   #16
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
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))$"
ownedbycats is offline   Reply With Quote
Old 02-09-2021, 09:56 AM   #17
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
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:
Originally Posted by ownedbycats View Post
I was trying to make a second regex to account for ISBNs with spaces/dashes. Did I make a mistake with the regex or the search syntax here?

https://regex101.com/r/vJUZpu/1

Code:
identifiers:"=isbn:~\d{1}(-|\s)\d{3}(-|\s)\d{5}(-|\s)\d{1}"
(I also need to figure out how to account for the X check digit)
replace the last term with [0-9X]
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
theducks is offline   Reply With Quote
Advert
Old 02-09-2021, 10:56 AM   #18
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,190
Karma: 1988646
Join Date: Aug 2015
Device: Kindle
Another approach that gives you more control:
  • create a stored template called isbn_count (preferences > template functions > stored templates). Use the following template:
    Code:
    program:
    	isbn = select(field('identifiers'),'isbn');
    	isbn = re(isbn, '[^\d]', '');
    	strlen(isbn)
  • You can now use the above stored template in the search bar (thanks to the newly added template search by chaley):
    Code:
    template:"program: isbn_count()#@#:n:=10"

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)
This way it does not matter where the dashes appear since they are removed before counting.

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"
I just think that using a stored template makes it cleaner and more readable.

Last edited by capink; 02-09-2021 at 12:58 PM.
capink is offline   Reply With Quote
Old 02-09-2021, 11:18 AM   #19
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,358
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by capink View Post
Code:
program:
	isbn = select(field('identifiers'),'isbn');
	isbn = re(isbn, '[^\d]', '');
	isbn = re(isbn, '(\d)', '\1,');
	count(isbn,',')
Without going too deeply into the previous posts to see if the answer is already there, it seems that this template is equivalent to the above, but faster.
Code:
program:
	isbn = select(field('identifiers'),'isbn');
	isbn = re(isbn, '[^\d]', '');
#	isbn = re(isbn, '(\d)', '\1,');
#	count(isbn,',')
	strlen(isbn)
chaley is offline   Reply With Quote
Old 02-09-2021, 11:23 AM   #20
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
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.
capink is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 03:24 AM.


MobileRead.com is a privately owned, operated and funded community.