View Single Post
Old 02-12-2012, 01:31 PM   #4
chaley
"chaley", not "charley"
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: 5,003
Karma: 802238
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
Originally Posted by Noughty View Post
Here looks like something I could use:
http://manual.calibre-ebook.com/sub_groups.html the last paragraph

Is it possible to somehow make it extract the tags like this only if there are sublevels. If there is a singe tag Anthology to leave it alone? With tags which have levels it should work fine now. I can make sure levels match so only what I don't need is removed. But the one level tags make a problem since they dissapear
Assuming you really want to do this and you are willing to use a column built from other columns, there are ways to do it. For example, the template
Code:
{#genre:'list_sort(list_union('', re(subitems($, 0, 2), '(^|,)([^,]*?)\.', '\1 '), ','), '0', ',')'}
will give you all single-level tags and the second item in a hierarchical tag (the B in A.B.C). The subitems function gives the first two levels (or first if there is only one). The re function strips everything from the beginning of the item to the period. The list_union removes duplicates, and the list_sort sorts the resulting list.

If you want everything except the first item (A.B.C returns B.C) then try this
Code:
{#genre:'list_sort(list_union('', re($, '(^|,)([^,]*?)\.', '\1 '), ','), '0', ',')'}
The subitems isn't needed because the entire tag is processed to remove the first element.
chaley is offline   Reply With Quote