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

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

Notices

Reply
 
Thread Tools Search this Thread
Old 03-16-2011, 05:49 AM   #1
adept22
Junior Member
adept22 began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Mar 2011
Device: Kindle
Help with a Regex Expression?

Hi, I am currently playing around with calibre and i need to try and get a regular expression to work that im having trouble with. If somebody is a guru and can help that would be great.

I have the below 2 examples of data
Darksaber
The Jedi Academy 03 - Champions of the Force

I currently have the expression
Code:
(.*?)([\d\d]+) -( .*)(?:)
In calibre when i use the \1 (Group 1) i get:
Darksaber
The jedi Academy

\2 u get:
Darksaber
03

\3 I get:
Darksaber
Champions of the force

Basically for the /1 and the /2 i dont want darksaber to appear. the \1 \2 group should only show a result when the input string has a Dash in it.

Is anybody able to help?
adept22 is offline   Reply With Quote
Old 03-16-2011, 06:36 AM   #2
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
I don't understand what you're trying to do. Where does that Darksaber stuff come from, anyway? The second line looks like it could be from the title metadata field, and from what I can see, the groups' second lines (the stuff after the Darksaber) are as one would expect, but I don't understand where the Darksaber in the group results is coming from. What metadata field is that string contained in?
Also, looking at your expression, the last group
Code:
(?:)
isn't doing anything. The syntax is for a non-grouping parentheses, but it's empty. In your second group, using the square brackets is unnecessary. You should use something like
Code:
(\d+)
for any number or, if the series index always has two digits and only two digits, use
Code:
(\d\d)
or
Code:
(\d{2})

Last edited by Manichean; 03-16-2011 at 06:38 AM. Reason: fixed regex being drawn as smiley
Manichean is offline   Reply With Quote
Old 03-16-2011, 06:50 AM   #3
adept22
Junior Member
adept22 began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Mar 2011
Device: Kindle
Ok i have changed it to
Code:
(.*)(\d+) -( .*)
but it still doesnt do what i want. Im figuring its something to do with the first bit?

Basically in the TITLE field i have imported a heap of books, now some belong to a series and some dont. the ones with the - contain the series the ones without dont. Now i cant pickup this up at the import stage as i am actually already using the series import as the reading order. The filename is "Readingorder 01 - The Jedi Academy 03 - Champions of the Force" for example and the other is "Readingorder 02 - Darksaber".
WHat i do i import the reading order in as the series, then search replace that to the custom reading order field. Now i am trying to where theres a - split the series info into the series field.
adept22 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
Need help with expression Gurkburken Conversion 1 03-08-2011 02:20 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 regex expression daesdaemar Workshop 4 02-19-2010 07:38 AM
Need help with regex expression daesdaemar Workshop 18 02-07-2009 03:48 PM


All times are GMT -4. The time now is 07:50 AM.


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