[Koha] marcedit regular expression

Walls, Ian Ian.Walls at med.nyu.edu
Wed Sep 23 05:49:47 NZST 2009


Eric,


To me, it seems like the hardest part of the regex replacement is dealing with M/D/YYYY v. MM/DD/YYYY (and I assume that M/DD and MM/D are also possible?).  Running multiple replacements may be the way to go:

1.  s/d(\d[1,2])\/(\d[1,2])\/(\d[4])/$3-$1-$2/  # puts the year, month and day in the right order

2.  s/\b(\d)\b/0$1/g   # replaces single digit M or D with zero-padded MM or DD


My tests indicate this works for MM/DD, M/D, MM/D, and M/DD variations.

There may be a more elegant way to do this, perhaps even on a single line, but I think that line would be nigh on unreadable.  Handling the if/then conditional implicit in the zero-padding seems to require two lines worth of logic...

Hope this helps!



Ian Walls
Systems Integration Librarian
NYU Health Sciences Libraries
550 First Ave., New York, NY 10016
(212) 263-8687





-----Original Message-----
From: koha-bounces at lists.katipo.co.nz [mailto:koha-bounces at lists.katipo.co.nz] On Behalf Of Erik Lewis
Sent: Monday, September 21, 2009 8:52 AM
To: koha at lists.katipo.co.nz
Subject: [Koha] marcedit regular expression

Happy rainy morning from Georgia

I'm working on my full database conversion and most of it has been  
pretty straight forward however I have 2 nagging questions.

1)  Where have those who have migrated unicorn data translated the  
Item Category 1 and 2 subfields from the Sirsi 999 field to the Koha  
952?


2)  I'm having a problem with dates Sirsi stores them in the 999 as  
dMM/DD/YYYY or sometimes dM/D/YYYY.  The "d" is just a prefix.  I can  
select them with my limited Regex skill but I haven't been able to  
figure out how to convert them to YYYY-MM-DD.


I'm being pretty methodical about documenting my steps for data  
conversion with the hope that it will be helpful to others.


_______________________________________________
Koha mailing list
Koha at lists.katipo.co.nz
http://lists.katipo.co.nz/mailman/listinfo/koha

------------------------------------------------------------
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email.
=================================



More information about the Koha mailing list