Greetings, all. Trying to use Format Values and regex scripting to modify an existing field using elements of content from another field, as follows:
%field1% = Box Set 5: Early Tracks (1965) [2024]
%field2% = Box Set V: 1965–1985 [Ficticious Records FR-3791/8524601423791-01/8524601423791]
Format Values / %field2%: $regexp(%field2%,^(Box Set V:) 1965–1985 (\'['.+?\']')'$',\1 $regexp(%field1%,^Box Set 5: (.+? \(\d{4}(?:–\d{4})\)) \'['2024\']$',\1))
Desired result: %field2% = Box Set V: Early Tracks (1965) [Ficticious Records FR-3791/8524601423791-01/8524601423791]
Actual result: %field2% = Box Set V: Box Set 5: Early Tracks (1965) [2024]
Is what I want to do possible, and if so, what am I doing wrong?
I have tried this:
$regexp('Box Set V: 1965–1985 [Ficticious Records FR-3791/8524601423791-01/8524601423791]',^(.*\:) \d+–\d+ (.+?)'$',$1 $regexp('Box Set 5: Early Tracks (1965) [2024]','^.*: (.*?) (\(\d{4}\)) \[\d+\]$',$1 $2) $2)
You will recognize the contents of FIELD1 and FIELD2
That expression leads to:
Box Set V: Early Tracks (1965) [Ficticious Records FR-3791/8524601423791-01/8524601423791]
Ok, thanks. I was still beating my head against a wall trying to figure out why my method didn’t work, but think I got it now. My original code was:
$regexp(%field2%,^(Box Set V:) 1965–1985 (\'['.+?\']')'$',\1 $regexp(%field1%,^Box Set 5: (.+? \(\d{4}(?:–\d{4})\)) \'['2024\']$',\1))
…but I failed to account for that extra part (?:–\d{4}), which may or may not need to be matched — some of my use cases have year ranges such as (1967–1968) — so it needed to be (?:–\d{4})?. Now it works.