Ad

Need A Regex To Modify A Second Match And Ignore The First And Last

- 1 answer

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

Ad

Answer

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.

Ad
source: stackoverflow.com
Ad