View Single Post
Old 08-13-2009, 12:11 PM   #8
oldcrow74 began at the beginning.
Posts: 15
Karma: 10
Join Date: May 2009
Device: sony prs-700bc
Originally Posted by ilovejedd View Post

(?P<author>.+?) - (\[(?P<series>.+?) (?P<series_index>[0-9]+)\] - )?(?P<title>.+)


(?P<author>.+?)( - (\[(?P<series>.+?) (?P<series_index>[0-9]+)\])? - (?P<title>.+)

would work. If you don't have any filenames with series information, then the following might be simpler:

(?P<author>.+?) - (?P<title>[^_]+)
No, none of these work. The first 2 don't parse out the author and title at all. The "simple" one is close, but always truncates the last word of the title.

Maybe I'm not making myself clear. This should be a very simple string operation. Except, apparently, in Python. I want everything to the left of the leftmost hyphen to be the author. Everything to the right of the leftmost hyphen, including other hyphens, is the title. For example, if the filename is

Aaaaaaa, Bbbbb - Qqqqqqq Rrrrr - Sssssssss Ttttttttt.pdf

the author is Aaaaaaa, Bbbbb

the title is Qqqqqqq Rrrrr - Sssssssss Ttttttttt

Thanks again,
oldcrow74 is offline   Reply With Quote