|
|
#1 |
|
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,361
Karma: 79528341
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 11:27 PM. |
|
|
|
|
|
#2 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,525
Karma: 8065948
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: 11,361
Karma: 79528341
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I tested and ^ will work.
|
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Search & Replace in multi value field | sasilk | Library Management | 14 | 03-26-2020 03:15 AM |
| Search and Replace: want to remove value that matches another field | einniv | Library Management | 0 | 07-25-2013 09:18 PM |
| Using Search & Replace with Identifiers field | BookJunkieLI | Calibre | 6 | 11-13-2012 02:20 PM |
| Search/Replace from Title Field to Pubdate | TMSxMR | Library Management | 5 | 08-06-2012 04:40 AM |
| Variable Search, Replace & Transfer to a new field | flopis | Library Management | 10 | 03-09-2011 12:41 PM |