Catman...ace_all(3pm)

πŸ“¦
version 1.320 Β· 4 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

✨ NAME ✨

Catmandu::Fix::marc_replace_all β€” it's a regex search-and-replace situation for (sub)field values in a MARC file, bestie πŸ’…

(also hi, this is a Perl manual page, 3pm section, from the User Contributed Perl Documentation collection β€” iykyk 🫢)


🌸 SYNOPSIS 🌸

# Append to all the 650p 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}')

like, four lil examples, all of them eating, no notes πŸ”₯


πŸ’– DESCRIPTION πŸ’–

okay so basically: you use regex search and replace on MARC field values. that's the whole vibe. regex goes in, shiny new field value comes out ✨


πŸŽ€ METHODS πŸŽ€

marc_replace_all(MARC_PATH , REGEX, VALUE)

For each (sub)field that matches the MARC_PATH, it takes the pattern found by REGEX and swaps it out for a new VALUE πŸ‘‘

That VALUE can be either:

  • a literal β€” just a plain string, straightforward, iconic
  • or a reference to an existing field</...> in the record, using the dollar JSON_PATH syntax, like $.x.y.z πŸ’«

no cap, that's the whole method 🫢


πŸ¦‹ INLINE πŸ¦‹

This Fix can be used inline in a Perl script, bestie:

use Catmandu::Fix::marc_replace_all as => 'marc_replace_all';

my $data = { record => [...] };

$data = marc_replace_all($data, '245a', 'test' , 'rest');

main character energy fr fr πŸ’…


πŸ‘‘ SEE ALSO πŸ‘‘

  • Catmandu::Fix

and that's the page, girlies πŸ’œ this lil doc came from <b>perl v5.38.2</b> and it was dated <b>2024-08-03</b> β€” user contributed Perl documentation, slay, go forth and regex responsibly πŸŒˆβœ¨πŸŽ€

πŸ“¦ where this page comes from