View Single Post
Old 01-01-2010, 01:40 AM   #23
mezme
Connoisseur
mezme began at the beginning.
 
Posts: 59
Karma: 10
Join Date: Dec 2009
Device: PRS700
Speaking of regex help... maybe some of the experts on here can help this beginner out

My files are formatted in the following ways:
option A -> Author ~ Title
option B -> Author ~ Title - [Series 00]
option C -> Author ~ Title - [Collection 00 - Series 00]

I have finally got the following regex to work correctly for option B and option C
(?P<author>.+?) ~ (?P<title>.+?)(\s-\s)\[(?P<series>.*)\s(?P<series_index>[0-9.]*)\]?

Here is what I get when I run the REGEX on the following format(Author ~ Title) I get the following, which is what I DO NOT want... I want it to also separate the author and title even when there isn't a series
Title = Author ~ Title
Author = No Match
Series = No Match

If I run it with (Author ~ Title - [Series]) I get the following which is what I want:
Title = Title
Author = Author
Series = Series [Series Index]

If I run it with (Author ~ Title - [Collection - Series]) I get the following which is what I want:
Title = Title
Author = Author
Series = Collection - Series [Series Index]

However, I won't recognize Option A... how can I get it to read the author and title correctly if there is NO series?

Last edited by mezme; 01-01-2010 at 01:46 AM.
mezme is offline