View Single Post
Old 01-30-2010, 09:34 AM   #2
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by Dysonco View Post
AuthorLastname, AuthorFirstnames - BookSeries SeriesNumber - BookTitle.FileExtension

I've tweaked the regular expression (mostly by trial and error as I'm most definately not a programmer) to this:

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

Now this works fine on the filename example as above, but unfortunately fails when the BookSeries and SeriesNumber parts are missing (when its a single book and not a part of a series).

So for example:

Pratchett, Terry - Discworld 01 - The Colour Of Magic.pdf

Would work okay, but:

Pratchett, Terry - Strata.pdf

Wouldn't.
This is what I'm using now:
Code:
^((?P<author>([^\-_0-9]+)(?=\s*-\s*)(?!\s*-\s*[0-9.]+)|\b))(\s*-\s*)?((?P<series>[^0-9\-]+) (- )?(?P<series_index>[0-9.]+)\s*-\s*)?(?P<title>.+)
It will parse your two examples and many others. Yours doesn't get the series_index. There are several regex threads here if you want more options.
Starson17 is offline   Reply With Quote