This kind of question has come up on the marcedit listserv a number of times over the past month. Users have been asking the following kinds of questions:
- I’d like to replace data in the Call Number and add [x] data, but only if the 020 does not have electronic resources in the text.
- I’d like to add a field, if [x] field isn’t present
- I’d like to edit [x] field, if it doesn’t have [x] text in a specific subfield.
Some of these questions are easier to answer than others prior to the update posted last night (5/30/2018). In the past, I would usually answer many of these questions using one of two responses.
- Using negative assertions within regular expressions
MarcEdit’s regular expression engine (the .NET Regular Expression Language) supports negative assertions. This allows you to do “not” matches. So, say you have a set of ebooks, and wanted to attach [eb] to the end of the data within a call number. You need a way to isolate just the items missing these values — so a negative match. In the regex language, this would mean using a negative assertion (?!…). This would look something like:
Find: (=09[09].*)(\d{4])(?!eb)(.*)This statement should generally match call numbers in fields 090 and 099 that have a date but no eb at the end of that date. The group: (?!eb) creates that negative assertion.
- Using the NOT statement in the Conditional Replace function.
In the MarcEdit Replace All function, the conditional replace option allows users to use the NOT keyword to identify either HAS or Regular Expression statements that do not match. This simplifies the process, as a user doesn’t have to create a negative assertion, and this match can be across any data in a record. In this case, the NOT keyword is formatted by the presence of the word: NOT in capital letters, and the space…prior to the statement being processed. For example:
In this example, the tool will replace the text CLSU with OSULTEST anywhere within a record [I could have targeted a specific field — I didn’t for this example), but only if the text =088 (or the 088 field) does not exist. The presence of the NOT keyword initiatives NOT processing rules. Note, this format is precise. NOT will not be initiative if this statement was formatted as: not =088. For the purpose of this function, the statement case is important, and required to initiate the NOT keyword matching. - The final use case — adding a new field if a field or text isn’t present — is actually a lot more difficult with current tools. In fact, I would often advocate that this be a multi-step process. However, if a user wants to create a task for this kind of operation, that wouldn’t be easily accomplished. To solve this problem, I extended the NOT functionality to the Add/Delete field function. Say you want to add a 500 field if an 088 field doesn’t exist, you can now do this in one step.
Like the Replace All function, the extension of the NOT functionality allows users to create targeted NOT statements that can then be used to simplify the process of handing the addition of fields based on negative matching operations without the need of creating work arounds. This new function was added to MarcEdit 7 in 5/30/2018, and will make its way to the Mac and Linux versions the first weekend of June 2018.
Hopefully, this information is useful. If you have questions, please let me know.
–tr