MarcEdit provides lots of different ways for users to edit their data. However, one use case that comes up often is the ability to perform an action on a field or fields based on the presence of data within another field. While you can currently do this in MarcEdit by using tools to isolate the specific records to edit, and then working on just those items — more could be done to make this process easier. So, to that end, I’ve updated the Replace Function to include a new conditional element that will allow MarcEdit to presort using an in-string or regular expression query, prior to evaluating data for replacement. Here’s how it will work…
When you first open the Replace Window:
Notice that the conditional string text has been replaced. This was confusing to folks – because maybe that didn’t reflect exactly what was being done. Rather, this is an option that allows a user to run an instring or Regular Expression search across your entire record before the Find/Replace is run. The search options grouped below – these *only* affect the Find/Replace textboxes. They do not affect the options that are enabled when the Perform Find/Replace If…is checked. Those data fields have their own toggles for instring (has) or regular expression (regex) matching.
If you check the box, the following information will be displayed:
Again – the If [Textbox] [REGEX] is a search that is performed and must evaluate as true in order for the paired find and replace runs. The use case for this function are things like:
- I want to modify the field x but only if foobar is found in field y.
There are other ways to do this by extracting data from files and creating lots of different files for processing or writing a script – but this will give users a great deal more flexibility when wanting to perform options, but only if specific data is found within a field.
A simple example would be below:
This is a non-real world example of how this function works. A user wants to change the 050 field to an 090 field, but only if the data in the 945$a is equal to an m-z. That’s what the new option allows. By checking the Perform Find/Replace If option, I’m allowed to provide a pre-search that will then filter the data sets that I’m going to actually perform the primary Find/Replace pair on. Make sense? I hope so.
Finally – I’ve updated the code around the task wizard so that this information can be utilized within tasks. This enhancement will be in the next available update.