---
name: "Catmandu::Fix::marc_replace_all"
section: "3pm"
platform: "linux"
package: "libcatmandu-marc-perl"
version: "1.320-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Catmandu::Fix::marc_replace_all"
---

# Catmandu::Fix::marc\_replace\_all(3pm)

regex replace (sub)field values in a MARC file

## NAME

Catmandu::Fix::marc\_replace\_all - regex replace (sub)field values in a MARC file

## SYNOPSIS

```
    # 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}')
```

## DESCRIPTION

Use regex search and replace on MARC field values.

## METHODS

### marc\_replace\_all(MARC\_PATH , REGEX, VALUE)

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.

## INLINE

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');
```

## SEE ALSO

Catmandu::Fix
