![]() |
#1 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,876
Karma: 74203799
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Help with a search&replace
I wanted to make some search & replaces for an Action Chain to populate one column based on values from another, like these (note the latter should also be 'prepend to field,' I forgot to set it before screenshotting it):
As the results show, it also copies all values from Genre (tag-like composite) instead of just the one i want. What should I do? ![]() Last edited by ownedbycats; 03-07-2021 at 10:07 PM. |
![]() |
![]() |
![]() |
#2 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,689
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,400
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
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 It seems that what you want is: Code:
for each book: if #genre contains text then add new_text to #kobocoll 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
Last edited by chaley; 03-08-2021 at 08:47 AM. |
![]() |
![]() |
![]() |
#4 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,876
Karma: 74203799
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I'll try that. Hopefully it won't overwrite other existing entries.
![]() EDIT: I used the template. It worked and did not remove existing entries. Last edited by ownedbycats; 03-08-2021 at 07:05 PM. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Search & Replace changes in 3.0 | Phssthpok | Editor | 4 | 06-21-2017 04:04 AM |
Regex in search problems (NOT Search&Replace; the search bar) | lairdb | Calibre | 3 | 03-15-2017 07:10 PM |
Search & Replace Help | paulfiera | Conversion | 7 | 08-06-2015 03:52 AM |
Help with a search & replace | mmholt | Library Management | 11 | 10-21-2011 06:49 PM |
Search & Replace | Pat Nickholds | Sigil | 2 | 10-21-2010 11:18 PM |