Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 12-03-2010, 07:52 PM   #1
krendk
Junior Member
krendk began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Dec 2010
Device: ipad iphone
Post Regular expression help

Being a non programmer and after having searched I have not been able to compile a regular expression structure that covers the following file format

<Title> by <Authors> at <Publisher> - <ISBN-10> - <ISBN-13>

Help would nice

Thanks in advance

Kren
krendk is offline   Reply With Quote
Old 12-03-2010, 11:35 PM   #2
thrawn_aj
quantum mechanic
thrawn_aj ought to be getting tired of karma fortunes by now.thrawn_aj ought to be getting tired of karma fortunes by now.thrawn_aj ought to be getting tired of karma fortunes by now.thrawn_aj ought to be getting tired of karma fortunes by now.thrawn_aj ought to be getting tired of karma fortunes by now.thrawn_aj ought to be getting tired of karma fortunes by now.thrawn_aj ought to be getting tired of karma fortunes by now.thrawn_aj ought to be getting tired of karma fortunes by now.thrawn_aj ought to be getting tired of karma fortunes by now.thrawn_aj ought to be getting tired of karma fortunes by now.thrawn_aj ought to be getting tired of karma fortunes by now.
 
thrawn_aj's Avatar
 
Posts: 705
Karma: 483827
Join Date: Aug 2010
Location: NorCal
Device: Nook1, Samsung Transform, Nook2
How about this?

Code:
(?P<title>.+) by (?P<author>.+) at (?P<publisher>.+) - (?P<ISBN-10>.+) - (?P<ISBN-13>.+)\.pdf
Note1: I added the \.pdf as an example. Be sure to add the file extension you have or the search will fail even if the rest of the regex is correct (maybe that was your problem?).

Note2: I suspect that this will fail dramatically if <title> contains "by" as a separate word.

Note3: I don't recall the actual labels for the 2 isbn fields. My (possibly obsolete) knowledge of this tells me that only 1 isbn field is supported. Dunno how far custom metadata has come. Assuming that isbn-13 is not usable, this is what I would do:

Code:
(?P<title>.+) by (?P<author>.+) at (?P<publisher>.+) - (?P<isbn>.+) - ([0-9]+)\.pdf
(if you want to save the ISBN-10 and throw away the ISBN-13. Make appropriate changes if you want it the other way round).

If custom metadata fields are supported (I just don't know), the following might work:

Code:
(?P<title>.+) by (?P<author>.+) at (?P<publisher>.+) - (?P<isbn>.+) - (?P<isbn13>.+)\.pdf
(if you want to save the ISBN-10 to the normal Calibre ISBN field and the ISBN-13 to a custom field called "isbn13" - it has to exist of course).

It doesn't help that I'm at work and don't have Calibre in front of me to check this. Good luck though
thrawn_aj is offline   Reply With Quote
Advert
Old 12-04-2010, 04:51 AM   #3
Manichean
Wizard
Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.
 
Manichean's Avatar
 
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
Quote:
Originally Posted by thrawn_aj View Post
Note1: I added the \.pdf as an example. Be sure to add the file extension you have or the search will fail even if the rest of the regex is correct (maybe that was your problem?).
Note 1 to note 1: I don't think you need to add any extensions to the import regexes. From what I recall, Calibre automatically strips the extension from the filename, thus the regex never even seees the extension.
Manichean is offline   Reply With Quote
Old 12-04-2010, 09:17 AM   #4
krendk
Junior Member
krendk began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Dec 2010
Device: ipad iphone
Smile Thanks

Gentlemen,

thanks for your input - it works except for the publisher - why I don't know

Kren
krendk is offline   Reply With Quote
Old 12-04-2010, 04:32 PM   #5
thrawn_aj
quantum mechanic
thrawn_aj ought to be getting tired of karma fortunes by now.thrawn_aj ought to be getting tired of karma fortunes by now.thrawn_aj ought to be getting tired of karma fortunes by now.thrawn_aj ought to be getting tired of karma fortunes by now.thrawn_aj ought to be getting tired of karma fortunes by now.thrawn_aj ought to be getting tired of karma fortunes by now.thrawn_aj ought to be getting tired of karma fortunes by now.thrawn_aj ought to be getting tired of karma fortunes by now.thrawn_aj ought to be getting tired of karma fortunes by now.thrawn_aj ought to be getting tired of karma fortunes by now.thrawn_aj ought to be getting tired of karma fortunes by now.
 
thrawn_aj's Avatar
 
Posts: 705
Karma: 483827
Join Date: Aug 2010
Location: NorCal
Device: Nook1, Samsung Transform, Nook2
Quote:
Originally Posted by Manichean View Post
Note 1 to note 1: I don't think you need to add any extensions to the import regexes. From what I recall, Calibre automatically strips the extension from the filename, thus the regex never even seees the extension.
You're absolutely right - as I said, I didn't have Calibre to test it with.
The official manual explicitly warned about this so I figured that's what was tripping up OP's initial trials. Unfortunately, after reading it again, I see that I misread the last line - it was merely talking about the test filename, not the real one .
thrawn_aj is offline   Reply With Quote
Advert
Reply

Tags
regular expression


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expression Help Azhad Calibre 86 09-27-2011 02:37 PM
Regular Expression Help iKarampa Calibre 13 12-15-2010 07:17 AM
Regular Expression Help smartmart Calibre 5 10-17-2010 05:19 AM
Help with the regular expression Dysonco Calibre 9 03-22-2010 10:45 PM
I don't know how to use wilcards and regular expression.... superanima Sigil 4 02-21-2010 09:42 AM


All times are GMT -4. The time now is 11:39 PM.


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