Quote:
Originally Posted by mightymouse2045
Matches a fair bit, but if i want to reorder the fields it escapes me what I should move where...
|
The reason it's not easy to see what to move is that your expression is trying to match lots of variations.
Code:
^(?P<author>[^-]+)(\s*-\s*(\[?(?P<series>[^-0-9]+)\s*(?P<series_index>[0-9.]+)?]?)?)?.*?-\s*(?P<title>[^\]{[()]+\w)
That regex isn't even doing lookaheads, as for example in this one:
Code:
^(?P<author>([^\-_0-9]+)(?=\s*-\s*)(?!\s*-\s*[0-9.]+)|\b)(\s*-\s*)?(?P<title>[a-zA-Z1-9 ]) (\[(?P<series>[^0-9\-]+) (- )?\#?(?P<series_index>[0-9.]+)\])
It's easy, however, to see the order of the fields in each.
I keep several of the complex expressions stored, and match up the order between my book and my regex.
I know that as long as the filename has author immediately followed by title I should try the second, and if it has author followed by series, I should try the first one.
If the test works, fine. If not, and it's not immediately obvious how to modify it, I also keep several very simple regexes, and those are easy to change to match. Later, if I get time, I go back and rewrite the complex expression to also capture the new file so it will work the next time. The trick is just to match the order of the fields in the filename to the order in the regex.