[Koha] Regexp in MARC modification action

Mark Alexander marka at pobox.com
Thu Nov 23 08:48:07 NZDT 2017


I'm trying to use a MARC modification template to fix the 952$d field
in MARC records we receive from our library supply house.  This field
is supposed to be the acquisition date, but is coming to us in the
format YYYY/MM/DD instead of the required YYYY-MM-DD.  So I needed to
find a way to replace the slashes with dashes. 

I created a MARC modification template with a simple action that uses
the regular expression s/\//-/ig.  The UI for creating the action in
Koha implies that the "ig" modifiers are always used (though there
doesn't seem to be any way to change them).  My understanding of the
"g" modifier in Perl is that it causes the s// operator to "replace
globally, that is, all occurrences".  (This is a quote from an old
copy of "Programming Perl" by Wall et. al.)

Yet it doesn't seem that the "g" modifier is really being used.  When
I used this template on an imported MARC record, it changed the first
slash in 952$d, but not the second one.  So, for example, 2017/11/06
got changed to 2017-11/06.  I had to add a second action to the
template, identical to the first action, to cause the second slash to be
replaced. 

Am I misunderstanding the use of regular expressions in MARC
modification templates, and in particular the behavior of the "g"
modifier?  Or is this a possible bug?


More information about the Koha mailing list