Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 09-27-2010, 01:35 AM   #1
jhart711
Junior Member
jhart711 began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Sep 2010
Device: nook
Regular Expression For Adding Books

I am trying to work out an expression for adding epub ebooks into Calibre, but I am going around in circles.

I am using this code for files in this format Title - Series - Author.

(?P<title>.+) -? (?P<series>[^_0-9-]*)(?P<series_index>[0-9]*) - (?P<author>[^_].+) ?

But is doesn't work when the series is missing.

Can someone please help?

John

Last edited by jhart711; 09-27-2010 at 01:42 AM.
jhart711 is offline   Reply With Quote
Old 09-27-2010, 02:50 AM   #2
megachirops
Enthusiast
megachirops began at the beginning.
 
Posts: 31
Karma: 12
Join Date: Mar 2010
Device: Kindle 2, Kindle 3
Code:
(?P<title>((?!\s-\s).)+)\s-\s(?:(?P<series>.+)\s(?P<series_index>\d+)\s-\s)?(?P<author>.+)
Give that a whirl.
megachirops is offline   Reply With Quote
 
Advertisement
Old 09-27-2010, 05:22 AM   #3
Manichean
Wizard
Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!
 
Manichean's Avatar
 
Posts: 3,130
Karma: 80520
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
Quote:
Originally Posted by jhart711 View Post
(?P<title>.+) -? (?P<series>[^_0-9-]*)(?P<series_index>[0-9]*) - (?P<author>[^_].+) ?
I think you got too many whitespaces in there for it to work when the series is missing: You'd have to have three spaces between the title and the author in that case.
Manichean is offline   Reply With Quote
Old 09-27-2010, 07:51 AM   #4
jhart711
Junior Member
jhart711 began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Sep 2010
Device: nook
That worked perfectly. Thanks.
jhart711 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expression Help Azhad Calibre 86 09-27-2011 03:37 PM
Calibre book adding: Regular expression request... Spiffy Calibre 29 09-12-2011 11:59 AM
Regular Expression Help smartmart Calibre 5 10-17-2010 06:19 AM
Helping importing books using regular expression askyn Calibre 4 05-08-2010 02:06 AM
Help with the regular expression Dysonco Calibre 9 03-22-2010 11:45 PM


All times are GMT -4. The time now is 06:33 AM.


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