Figured out how to get this to work yesterday and thought it might be useful to share in case anyone else was as mystified as I was.
MarcEdit provides a conditional Find and Replace function that let’s you find something and replace it only if the associated condition is true. You can use a regular expression or “regex” to set the condition that must be met.
This example searches each MARC record for a particular string and if the string is present will perform the find and replace. Specifically I wanted to change the message in MARC field 516 from “Electronic monograph” to “Electronic journal”, but only if the MARC 856 contained the string “HeinOnline Law Journal Library”.
This is how it looks in MarcEdit:
And here’s the regex bit:
(=856)(.+\$3HeinOnline Law Journal Library)
This looks in the MARC 856 subfield 3 for the string “HeinOnline Law Journal Library”. I am by no means a regex expert but here’s my explanation.
The ( ) define a “marked expression”, there are two here the MARC syntax for the 856 field in MarcEdit, i.e. =856 and then the subfield 3 and associated string. The . matches any single character and the + says to match the preceding element one or more times; so any number of characters before the subfield. The \ is the “escape sequence” that allows the $ to be read as a character rather than as its usual status as a metacharacter that matches the “end of a line or string.”
Anyway, it works nicely!