![]() |
#1 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,973
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Search & Replace: Prepending something in the comments field
I wanted to add a series description to some book comments. So I did this.
Search mode: regex Search field: comments Search for: .* Replace with: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Destination field: comments Mode: Prepend to field This resulted in the replacement text appearing multiple times: ![]() What did I do wrong? Last edited by ownedbycats; 04-03-2021 at 10:27 PM. |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
In Python 3 the regexp engine changed. The pattern .* matches both the zero-width 'thing' at the beginning of the line and the entire line. Because there were two matches your string was prepended twice.
Use either ^, which matches before the first character, or .+, which won't do a zero-width match. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,973
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I tested and ^ will work.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Search & Replace in multi value field | sasilk | Library Management | 14 | 03-26-2020 02:15 AM |
Search and Replace: want to remove value that matches another field | einniv | Library Management | 0 | 07-25-2013 08:18 PM |
Using Search & Replace with Identifiers field | BookJunkieLI | Calibre | 6 | 11-13-2012 01:20 PM |
Search/Replace from Title Field to Pubdate | TMSxMR | Library Management | 5 | 08-06-2012 03:40 AM |
Variable Search, Replace & Transfer to a new field | flopis | Library Management | 10 | 03-09-2011 11:41 AM |