View Single Post
Old 09-08-2012, 04:16 PM   #1
kanigetts
Junior Member
kanigetts began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Sep 2012
Device: Kindle 4
My RegEx works in Test but not for Add Books

I have a RegEx that I customized to Add Books and populate metadata. It works perfectly in the test but has different behavior when in actual use. It also works perfectly using RegEx Buddy software with the Python settings so it seems correct. What could account for the change in behavior? My RegEx:

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

The String: BookSeries - 01 - Book Title - Book Author.epub

Test Result:

Author: Book Author
Series: BookSeries
Series Index: 01
Title: BookSeries - 01 - Book Title

Add Books Result:

Author: Book Author
Series: BookSeries
Series Index: 01
Title: Book Series - 01 - Book Title

If I change it slightly so that the input file name has two words before the first "-", it works fine in both the test and add books as well as in Regex Buddy. Like this:

The String: Book Series - 01 - Book Title - Book Author.epub

Test Result:

Author: Book Author
Series: Book Series
Series Index: 01
Title: Book Title

Add Books Result:

Author: Book Author
Series: Book Series
Series Index: 01
Title: Book Title

I've messed with it and had a number of variations that also worked fine in test and with RegEx Buddy, but still no love when I add books. I can't figure out why it seems to need two words before the "-", but only in Add Books. I'm just beginning to understand and use Regular Expressions and this one has me stumped. It's especially frustrating since I get different results with Test and Add Books.
kanigetts is offline   Reply With Quote