DOKK / manpages / debian 12 / libcatmandu-marc-perl / Catmandu::Fix::marc_replace_all.3pm.en
Catmandu::Fix::marc_replace_all(3pm) User Contributed Perl Documentation Catmandu::Fix::marc_replace_all(3pm)

Catmandu::Fix::marc_replace_all - regex replace (sub)field values in a MARC file

    # Append to all the 650-p values the string "xyz"
    marc_replace_all('650p','$','xyz')
    # Replace all 'Joe'-s in 100a to 'Joey'
    marc_replace_all('100a','\bJoe\b','Joey')
    # Replace all 'Joe'-s in 100a to the value in field x.y.z
    marc_replace_all('100a','\bJoe\b',$.x.y.z)
    # Replace all the content of 100a with everything in curly brackets
    marc_replace_all('100a','^(.*)$','{$1}')

Use regex search and replace on MARC field values.

For each (sub)field matching the MARC_PATH replace the pattern found by REGEX to a new VALUE. This value can be a literal or reference an existing field in the record using the dollar JSON_PATH syntax.

This Fix can be used inline in a Perl script:

    use Catmandu::Fix::marc_replace_all as => 'marc_replace_all';
    my $data = { record => [...] };
    $data = marc_replace_all($data, '245a', 'test' , 'rest');

Catmandu::Fix

2022-09-27 perl v5.34.0