View Single Post
Old 11-28-2010, 10:25 AM   #1
Dragonator
Junior Member
Dragonator began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Nov 2010
Device: none
A little help adding books and using regex.

Hello.

I love Calibre and use it to organize my ebook library. It's awesome.

I do have one issue though: the regular expression that deals with the name of the file being added. I'm sure this is a common issue with a simple solution that would make me feel like an idiot for not figuring it out. The thing is I have never gotten along too well with regular expressions so I need a little help. For the record I have looked up regular expressions as used by calibre and tried to figure them out, then tried to look for a solution. I really hope some helpful soul will lend me a hand.

The files I add are usually named in two ways depending on if they are part of a series or not:

author_name - series_name series_index - book_title.extension

or

author_name - book_title.extension.

The regular expression I use is this:

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

which works well when adding series but not when adding individual books, which is when I edit the prefferences and delete the middle part resulting in this:

(?P<author>[^_]+) - (?P<title>.+)

I kept trying to make the deleted part optional so it would work in both cases automatically but I just can't get my head around it. Is it possible to come up with a regular expression that deals with both cases favorably?

Thank you.
Dragonator is offline   Reply With Quote