Skip to main content
August 11, 2017
Answered

Add hyphens to ISBN number

  • August 11, 2017
  • 2 replies
  • 1381 views

Hi, I have a catalogue with 13 digit ISBN numbers in the following format: 9781107000000

but I need to add hyphens so that they look like: 978-1-107-00000-0

I reckon GREP is the way but I'm pretty hopeless at that. Any ideas?

Many thanks!

This topic has been closed for replies.
Correct answer vladan saveljic

try this grep:

find

\b(\d{3})(\d)(\d{3})(\d{5})(\d)\b

change

$1-$2-$3-$4-$5

2 replies

Legend
August 11, 2017

This may be worth mentioning. The grep will be fine if you are working only with books from one publisher, CUP, with code 1-107. If you are doing this in general you may not know that the sections in an ISBN are of different lengths. Even those from the same publisher...

Other ISBN ranges for Cambridge University Press: Cambridge University Press (978-0-511-...) · Cambridge University Press (978-0-521-...) · Cambridge University Press (978-0-931837-...) · Cambridge University Press (978-0-949009-...) · Cambridge University Press (978-1-108-...) · Cambridge University Press (978-1-139-...) · Cambridge University Press (978-1-316-...) · Cambridge University Press (978-1-4213-...) · Cambridge University Press (978-1-55899-...) · Cambridge University Press (978-4-902290-...) · Cambridge University Press (978-84-8323-...) · Cambridge University Press (978-84-9036-...) · Cambridge University Press (978-93-82993-...)

vladan saveljic
vladan saveljicCorrect answer
Inspiring
August 11, 2017

try this grep:

find

\b(\d{3})(\d)(\d{3})(\d{5})(\d)\b

change

$1-$2-$3-$4-$5

August 11, 2017

Many thanks - that was perfect!

Much appreciated.