View Single Post
Old 03-28-2022, 03:38 PM   #366
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,511
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
New question:
[...]
Is there a way to do either of the following?

1. Tell it to skip to the next tag if it finds [Cleanup].
2. Tell it to search for the first (foo|bar) tag, where the pattern matches the enumerated values.

I suspect the latter would be a better option as I sometimes don't clean up bulk-imported tags first, so something like 'Animals' or 'Biography' would come up before Fiction|Nonfiction.

Thanks.
First issue: the idea of "first". There is no guaranteed order of the tags in the list. Second: there isn't a template function that returns the valid values for an enumerated column.

If you mean "match any of a list of tags such as "Fiction|Nonfiction" then you can do that.
Code:
program:

	if $#fanficcat then 'Fanfiction'
	elif $#manualtype then 'Documentation & Manuals'
	else
		t = list_intersection($tags, "Fiction, Nonfiction", ',');
		re(sublist(t, 0, 1, ','), '^(.*?)($|\..*$)', '\1')
	fi
That said, I don't know what the re() is doing so I don't know whether what I suggest can work. It looks like it is trying to isolate the first part of a hierarchical tag. If so then this might work by getting the first of an acceptable value:
Code:
program:

	if $#fanficcat then 'Fanfiction'
	elif $#manualtype then 'Documentation & Manuals'
	else
		sublist(list_intersection(subitems($tags, 0, 1),  "Fiction, Nonfiction", ','), 0, 1, ',')
	fi

Last edited by chaley; 03-28-2022 at 05:02 PM.
chaley is offline   Reply With Quote