Quote:
Originally Posted by Dysonco
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.