View Single Post
Old 12-11-2021, 07:21 AM   #205
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,475
Karma: 8025702
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
I think I identified the misbehaving template.

New question (likely more regex issue): When using a 'contains' on a taglike, how can I make it match when there's multiple options? e.g.

Code:
program:
   f = field('#field');
   strcat
   (
    contains(f, "^foo|bar|foobar|test123$", 'icon.png:', ''),
   )
it sometimes breaks if "test123" is in the taglike. It works again if I remove the exact-match modifiers but then it's not exact matching.
Are you sure that you want contains() on a tags-like column? The contains() function looks at the string of tags as a single element, not as a list. As such, if the column value is 'foo, zorro' then your expression can never match. It will succeed only if the column contains a single value, which raises the questions "why is it tags-like?".

This expression checks for the existence of any one of the tags, ignoring whether or not other tags also exist.
Code:
program:
	f = field('#mytextmult');
	strcat
		(
			if "^(foo|bar|foobar|test123)$" inlist f then 'icon.png:' fi
		)
Alternatively, this, which is closer in spirit to what you did.
Code:
program:
	f = field('#mytextmult');
	strcat
		(
			list_contains(f, ',', "^(foo|bar|foobar|test123)$", 'icon.png:', '')
		)
chaley is offline   Reply With Quote