Doug and Terry,
Thank you!
Not only did that work (well, Doug's did. I don't know why Terry's did not.), but I am beginning to understand how to think about the reg exs.
And thank you, too, for these links. I'll start with those.
Matthew
-----Original Message-----
From: MarcEdit support in technical and instructional matters [mailto:[log in to unmask]] On Behalf Of Doug Rippey
Sent: Monday, September 27, 2010 2:28 PM
To: [log in to unmask]
Subject: Re: beginner's question about using reg ex
The key here is defining the variable part of the data you want the clever regex to "remember" for reuse, as distinct from the parts you (the clever human) are going to hardwire to change.
There is always more than one way to get the same result in regex, but I would try this:
Find: =520 ...a([1-9])
Replace with: =300 \\$a$1
[x] Use regular expressions
That "$1" in the Replace statement is a back reference to the class of characters inside the parentheses in the Find statement.
In [somewhat] plainer English, this command says
Find:
all occurrences of tag 520,
with any indicators
and a digit at the beginning of subfield a
Replace with:
a 300 tag
with two blank indicators
followed by a subfield a delimiter
and whatever digit was found at the beginning of that 520 $a
Some further regex info sources you might find helpful:
Introduction to Regular Expressions http://msdn.microsoft.com/en-us/library/28hw3sce.aspx
Regular Expression Cheat Sheet (.NET) http://regexlib.com/CheatSheet.aspx
Regular Expression Syntax http://msdn.microsoft.com/en-us/library/ae5bf541.aspx
Unfortunately, this overview doesn't address regex in any detail, but Terry does point out which MarcEdit tools can use regex
MarcEdit: Editing MARC records using the MarcEdit MarcEditor http://www.youtube.com/watch?v=kNMExHdki9k&feature=related
------------------------------------
Doug Rippey
Cataloging Technician IV
Penrose Library Serials Dept.
303.668.7669 (mobile)
library.du.edu
University of Denver
-----Original Message-----
From: MarcEdit support in technical and instructional matters [mailto:[log in to unmask]] On Behalf Of Beacom, Matthew
Sent: Monday, September 27, 2010 11:31 AM
To: [log in to unmask]
Subject: [MARCEDIT-L] beginner's question about using reg ex
Hi all,
I've never before written a reg ex and I have what I suspect is a very simple question, but I have not found the existing information on reg exs to be immediately useful in solving this for me. So I thought I might ask you all for help.
The situation is this. I have converted some OAI Dublin Core records into MARC21 (just using the existing MARCedit stylesheets), and thus I have two 520 fields in the MARC21. The one has a textual note, the other has extent data. For example, "=520 \\$a95 p." So I'd like to find all of those (easy enough with the reg ex--even I could do that), and replace either just the MARC tag "520" with "300" or all of the reg ex _except_ the last character (the numeral).
When I used a reg ex that I thought might work, MARCedit's find and replace actually just reproduced the character string of the reg ex. That seemed really odd to me. I could understand it not working the way I expected, but it simply used the initial reg ex to find the string to replace and then replaced it with the "replace reg ex" character string.
Here is the reg ex I used to find the string:
=520 \\\\\$a[1-9]
That worked. (And I got really impressed with how clever the reg ex can be.)
Here is the rather simple-minded reg ex I thought I might be able to use to replace the piece I wanted to replace and keep the numeral at the end of the string.
=300 \\\\\$a[1-9]
This did not work. (And, obviously, was a bit disappointed in my application of the quite clever little reg ex thing.)
As I said above, MARCedit simply input the reg ex as a string.
Thanks.
Matthew Beacom
Metadata Librarian
Yale University Library
[log in to unmask]
________________________________________________________________________
This message comes to you via MARCEDIT-L, a Listserv(R) list for technical and instructional support in MarcEdit. If you wish to communicate directly with the list owners, write to [log in to unmask] To unsubscribe, send a message "SIGNOFF MARCEDIT-L" to [log in to unmask]
________________________________________________________________________
This message comes to you via MARCEDIT-L, a Listserv(R) list for technical and instructional support in MarcEdit. If you wish to communicate directly with the list owners, write to [log in to unmask] To unsubscribe, send a message "SIGNOFF MARCEDIT-L" to [log in to unmask]
________________________________________________________________________
This message comes to you via MARCEDIT-L, a Listserv(R) list for technical and instructional support in MarcEdit. If you wish to communicate directly with the list owners, write to [log in to unmask] To unsubscribe, send a message "SIGNOFF MARCEDIT-L" to [log in to unmask]
|