Quote:
Originally Posted by gwk
Example 1:
Title contains: Hello world (by Smart Author)
Author contains: World series
Series contains:
Example 2:
Title contains: BookSeries 1 Hello world
Author contains: Smart Author
Series contains:
|
I am trying to work out how one would use cross-field templates here, other than to copy fields.
We have three things:
1) the metadata for a book. Say we are working on 'title'
2) the search expression
3) the target expression
What we do is:
book.meta('title') = re.sub(search_exp, target_exp, book.meta('title'))
We can't put a cross-field reference into search_exp, because then it won't match the metadata. We can put a cross-field reference into the target. Consider:
book.meta('series') = re.sub('', '\g<title>', book.meta('series'))
In your second example, series would now be 'BookSeries 1 Hello world'. You can now hack at it with further search/replaces.
However, I don't think that is what you really want. It seems to be that you really want to be able to say something like:
book.meta('series') = re.sub('(.*\d+) ', '\1', book.meta('title'))
Or perhaps you want both facilities?
book.meta('genre') = re.sub('(Fiction|Fantasy)', '\1 \g<#genre>', book.meta('tags'))
Do I have it right?
(Starson17, could you also answer this?)