View Single Post
Old 06-20-2017, 04:11 PM   #1
MontyJ
Addict
MontyJ began at the beginning.
 
Posts: 224
Karma: 10
Join Date: Jul 2012
Device: Kindle
Metadata Regex Search/Replace

Hola!

I am trying to do what I thought was going to be a simple search and replace in the metadata editor. Here's what I need to do:

Every once in a while I get a batch of books that seem to have a lot of the author initials run together and it becomes tedious to have to manually go through all the entries and manually edit them. So I need to look for connected uppercase letters in the authors field and separate them with a space. Example:

Smith, John XY, or
Smith, XY John, or
John XY Smith, or
Smith, XY

The "XY" needs to come out "X Y", ie a space inserted.

But NOT affect something like Smith, John Xy, or the other arrangements of that.

I have tried:
Code:
\b([A-Z]){2}\b
And that finds the right occurrence, but can't capture it so I can insert a space.

\b([A-Z])([A-Z])\b
But that fails on the "Xy" occurrence when I use the replacement of:

\1 \2
Note the space in between.
I have tried a half dozen other short and lengthy regex's I found, but none work for this situation..

Ideas?

Thanks!
MontyJ is offline   Reply With Quote