View Single Post
Old 06-03-2023, 07:19 PM   #630
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,085
Karma: 76037135
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Code:
	if 
		'^(Fiction|Nonfiction|Magazines & Publications)' in $#booktype 
	then 
## Remove 'Culture & Regions' items as they're processed differently
		split_tags = list_re_group($tags, ',', '.', '(^.*Cultures & Regions.*$)', '');
## Split tags or return an empty
		split_tags = re(split_tags, '\.', ',') 
	else
		split_tags = ''
	fi;

## Cultures & Regions - list_item with a '.' separator to get the lastmost item
	cultures_tags = list_re($tags, ',', 'Cultures & Regions', '');
	cultures_tags = list_item(cultures_tags, -1, '.');
## Re-merge this with split_tags
	split_tags = list_union(split_tags, cultures_tags, ',');
This removes the 'Culture & Regions' items from split_tags, extracts the lastmost item, and merges them back in.

However, it only works with one item. After splitting the culture_tags list with ',', how do I process each item separately?

Example: Fiction.Cultures & Regions.Canada.Western Canada, Fiction.Cultures & Regions.Metis, Fiction.Historical Fiction
Preferred result (after sorting): Historical Fiction, Metis, Western Canada
Actual result: Historical Fiction, Metis

Last edited by ownedbycats; 06-03-2023 at 07:22 PM.
ownedbycats is offline   Reply With Quote