Home > Software design >  Need a regex to modify a second match and ignore the first and last
Need a regex to modify a second match and ignore the first and last

Time:02-12

Library context, using MarcEdit which can also use regex.

I need this:

=773 \\$tEtudes inuit$x0701-1008$1Vol. 44 1-2, $2p. 53-84

to be changed to this:

=773  \\$tEtudes inuit$x0701-1008$1Vol. 44, no. 1-2, $2p. 53-84

Problem is, the 44 in this case and the 1-2 are numbers that will change from one book to the other and I am building commands to automate it.

I tried focusing on changing the space between the 44 and the 1-2 into a ', no. ' with \s but it obiviously changes all spaces characters.

The adding ', no. ' is easy because there is a different box for it but I can't focus on the 2nd space while ignoring the first and last and also keeping every characters before and after.

Thank you for helping, I've been looking/trying all day!

MarcEdit exemple

CodePudding user response:

If the regular expression implementation supports look ahead, you can require that this space is followed by a range and a comma:

Find: \s(?=\d -\d ,)
Replace: , no.

  • Related