View Single Post
Old 09-28-2011, 03:21 AM   #4
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Search and replace does nothing to the contents of a field if the search matches nothing, instead passing the field through unchanged. This is consistent with the definition: search for X, replace X with Y, then write the results back to the field. If X is not found, then the field is passed through without modification to be made available to the post-search functions. That is why in your case the entire string is being passed to series. I am not willing to change this behavior. There is too much risk of seriously breaking something.

What you should do is ensure that you are operating on books that will match the pattern you are using. Yes, I recognize that this is what you say you don't want to do, but it isn't as hard as you might be thinking. You first search your library for the books that match the pattern, then you select all the results, then do the search/replace.

For example, first search (using the search bar) for
Code:
author:"~(.*) - ([^-]+) - ([0-9]+)"
This will find all the books that match the pattern, in this case books with an author containing two dashes surrounded by spaces. You then do the search/replace on the results, using the same pattern. In this case, \1 captures the author, \2 captures the series, and \3 captures the series index. You would do three search/replaces to fix the three fields, probably in the destination order series, series_index, author.

One caveat: Author is a multiple field. If you have a book of the form
Joe Blogs - Whazzup - 1 & John Doe, things get rather complicated.
chaley is offline   Reply With Quote