Terry's original answer from March 21 was a little different:
Find: (=520.{4})(\$a)(?<words>([^ ]*\s){100})(.*)
Replace: $1$2${words}...
This regex looked for non-space characters followed by spaces, whereas the solution he offered today looks for word characters followed by spaces--two different things. Today's solution did not work in my test file.
But for Nick Curotto's question below, about trimming a line to a maximum of 80 characters, and not dividing a word, I found an answer on Stack Overflow that seems to work. It was posted by a contributor named dajo last December. For the 245 field, my adaptation here gave me the expected results:
Find: (=245.{4}\$a)(.{1,80}(?=\s|$))(.*)
Replace: $1$2
As I understand this, the Find expression looks to match at least one, but no more than 80, characters following the "$a" at the beginning of the field; and it stops at the last match that's followed by either a space or the end of the line. It also captures everything following that point, only to discard it: The Replace expression keeps only the tag and the following <= 80-character string.
*****************************************
Walter F. Nickeson, Catalog &
Metadata Management Librarian
Rush Rhees Library
University of Rochester
Rochester, NY 14627-0055
[log in to unmask]
(585) 273-2326 fax: (585) 273-1032
*****************************************
> -----Original Message-----
> From: MarcEdit support in technical and instructional matters
> [mailto:[log in to unmask]] On Behalf Of Terry Reese
> Sent: Thursday, April 06, 2017 10:54 AM
> To: [log in to unmask]
> Subject: Re: [MARCEDIT-L] reg ex help for abbreviated title field
>
> I posted something like this last week, the week before. It wasn't perfect
> because work breaks vary a lot, but if you use spaces to designate words,
> you could do something like this in the replace function:
>
> Find: (=245.{4}\$a)(?<words>(\w\s){80})
> Replace: $1${words}
>
> I'm writing this off the top of my head. If it doesn't work, let me know and I'll
> check the list archive for the syntax I wrote then.
>
> --tr
>
> -----Original Message-----
> From: Nick Curotto [mailto:[log in to unmask]]
> Sent: Thursday, April 6, 2017 10:45 AM
> To: [log in to unmask]
> Cc: Nick Curotto <[log in to unmask]>
> Subject: reg ex help for abbreviated title field
>
> Hello,
> I need to create an abbreviated title field with 80 characters or less. It would
> be ideal to trim the field following the last full word that will fit within the 80
> character limit but I'm not sure how difficult this would be.
>
> I used the Build New Fields tool to add 210 field:
>
> =210 \\$a{245$a}{245$b}
>
> and have been wrestling with the find and replace function but I have not
> been able to come up with a good solution.
>
> Any thoughts or ideas would be greatly appreciated.
> Nick
>
>
>
> Nick Curotto
> Virginia Museum of Fine Arts
> Margaret R. and Robert M. Freeman Library
> 200 N Boulevard | Richmond | VA | 23220-4007
>
> vmfa.museum/library
________________________________________________________________________
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]
|