Quote:
Originally Posted by ownedbycats
Here's what I wanted to do:
Tags: Fiction.Cultures & Regions.Canada, Fiction.Social issues.Prejudice and Racism
Results: Fiction, Canada, Prejudice and Racism
Unfortunately the template instead gave me Fiction, Cultures & Regions, Social Issues.
|
TBH this is approaching absurd. Why don't you set up your tags the way you want instead of using all this automation to mess with it? That way you control what you have without all the fuss.
The above notwithstanding, this might do what you want.
Code:
program:
g = field('#genre');
stripped_hierarchies = list_re_group(g, ',', '.',
'^(Fanfiction|Documentation and Manuals)($|\..*$)',
'{$}', '');
split_hierarchies = re(stripped_hierarchies, '\.', ',');
split_hierarchies = list_difference(
split_hierarchies,
'Cultures & Regions, Social Issues',
',');
cleaned = list_union('', split_hierarchies, ',');
sorted = list_sort(cleaned, 0, ',')