View Single Post
Old 10-23-2011, 10:12 PM   #2
Serpentine
Evangelist
Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.
 
Posts: 416
Karma: 1045911
Join Date: Sep 2011
Location: Cape Town, South Africa
Device: Kindle 3
It would help if you could give a larger sample set to work with, I am sure that this is over simplistic example that you have given

However, assuming that your set will always have the formatting given in your post as :
{author} - {series name} - {book title}
or as an example:
Some Author - Some Series - This Title Hrrr

The regex would be as simple as :
(?P<author>.+?) - (?P<series>.+?) - (?P<title>.+)

The pitfall would be titles that could have a spaced dash in them "Novel A - A Book About Things". There is also no provision for a series index. The following examples include two ways that may be more correct for series indices.

I think your real case is most likely closer to something like this :
Some Author - Some Series [4.0] - This Title Hrrr
regex : (?P<author>.+?) - (?P<series>.+?) (?:\[(?P<series_index>[\d\.]{1,4})\] )?- (?P<title>.+)

Or as the old regex expects :
Some Author - [Some Series 4.0] - This Title Hrrr
regex : (?P<author>.+?) - (?:\[(?P<series>.+?) ?(?P<series_index>[\d\.]{1,4})?\]) - (?P<title>.+)

If none of them match the case, feel free to either PM me a list or reply here with more examples.

Last edited by Serpentine; 10-23-2011 at 10:29 PM. Reason: a little fix
Serpentine is offline   Reply With Quote