View Single Post
Old 11-17-2023, 04:19 PM   #13
kjdavies
Zealot
kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.
 
Posts: 112
Karma: 53342
Join Date: Jun 2013
Device: Sony PRS-600
Quote:
Originally Posted by crnirg View Post
Why does UK appear twice?

Search mode: Regular...
Search field: author
Search for: (.*)
Replace with: UK
Destination field: authors
Mode: Append ti field
check - Split result
check - Case sensitive
-------------------------
author before : Juli Zeh
author after: Juli Zeh & UKUK
I tried with an author with a 'one-word name', one with an author with a 'two-word name', and with an author with a 'three-word name'. In all cases they want to append 'UKUK'.

At a guess, it's returning 'UKUK' because it sees the 'real string' and an 'empty string' (perhaps picking up the start or end of the string as a matching substring). When you have '.+' it can't match the empty string, so you get only a single 'UK'.

Still, when using regex to append or prepend a string to a field like this, I prefer to use the string-start and string-end special characters ('^' and '$' respectively) or to explicitly replace the entire thing, which looks like

Search: ^(.*)$
Replace: \1 UK

The search here says 'replace all characters' -- '(.*)' alone says 'replace any string of 0 or more characters, '^(.*)$' says 'replace the entire string' -- with 'those characters + " UK"'.
kjdavies is offline   Reply With Quote