View Single Post
Old 04-04-2012, 04:00 AM   #12
louwin
Newbie Nerd
louwin ought to be getting tired of karma fortunes by now.louwin ought to be getting tired of karma fortunes by now.louwin ought to be getting tired of karma fortunes by now.louwin ought to be getting tired of karma fortunes by now.louwin ought to be getting tired of karma fortunes by now.louwin ought to be getting tired of karma fortunes by now.louwin ought to be getting tired of karma fortunes by now.louwin ought to be getting tired of karma fortunes by now.louwin ought to be getting tired of karma fortunes by now.louwin ought to be getting tired of karma fortunes by now.louwin ought to be getting tired of karma fortunes by now.
 
louwin's Avatar
 
Posts: 114
Karma: 1000354
Join Date: Feb 2012
Location: Perth, Western Australia
Device: iPad 3 64Gb Black
Quote:
Originally Posted by Shadewing View Post
The books are all in txt format and come with names in of 3 formats:

Author - Title.txt
Author - Series - Title.txt
Author - Series - Series No. - Title.txt
Yeahhhhh!

This regex WILL do exactly what you want.

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

Author AND Title MUST be there!

Series and/or Series no may be there or not or one or the other.

The series no can have a decimal in it. I think 2.5 is a book later added between 2 and 3?

If only one of series or series no is present, I suspect Calibre knows which is which from the fact that the series no is numeric.

The author is transfered as entered but Calibre has an option to swap firstname and lastname.
louwin is offline   Reply With Quote