Search and replace operates on the individual values, not the set of them, changing only the text that matches. Any values that are not matched are not changed. Said another way, S&R does:
Code:
for each item in the list:
find text in item that matches the search expression
replace that text with the replacement expression
return the list with replacements
This is what you are seeing.
It seems that what you want is:
Code:
for each book:
if #genre contains text then add new_text to #kobocoll
As you are using action chains I would do this with a template in a single-field-edit action setting #kobocoll. The template would be something like this:
Code:
program:
g = field('#genre');
k = field('#kobocoll');
if list_contains(g, ',', '^Cozy Mystery$', '1', '') then
k = list_union(k, 'Cozy Mysteries', ',')
fi;
if list_contains(g, ',', '^(Fantasy|Science Fiction)$', '1', '') then
k = list_union(k, 'Fantasy & Sci-Fi', ',')
fi;
k
You can do it with two search/replace's. One would be something like this:
- source "Template"
- template
Code:
{#genre:'list_contains($, ',', '^Cozy Mystery$', 'Cozy Mysteries', '')'}
- Search for: '(.*)'
- Replace with '\1'
The other would be similar, with the other text values