View Single Post
Old 11-19-2012, 04:43 PM   #1
ianc
Member
ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.ianc ought to be getting tired of karma fortunes by now.
 
Posts: 12
Karma: 472024
Join Date: Nov 2012
Device: Samsung Galaxy S3
[Old Thread] Capitalize first word in sentence with search and replace?

Hi Folks,

I've converted a .PDF file to .epub and was able to remove the headers and footers with only a little difficulty.

I notice, however, that after the conversion, a lot of the capitalization at the beginning of sentences has been lost (unrelated to headers and footers), which is rather annoying.

It occurred to me to use a regex to locate lower case chars at the start of sentences. Initially, I could think of two cases:

1) First character in the sentence after a paragraph break. Can locate with "\.<br>\s+[a-z]"

2) First character in the sentence in the middle of a paragraph, assuming the previous sentence ends with a period and is followed by one space. Can locate with "\. [a-z]".

My question is, what should I use in the replacement text box to cause Calibre to substitute the upper case char for that which was found by the original search regex?

At first I just tried "\.<br>\s+[A-Z]" and "\. [A-Z]", but the replacement just took those literal text strings and wrote them into the book, so that, for example, every sentence beginning with a lower case character in the middle of a paragraph now begins with "\. [A-Z]" rather than the correct letter.

Thanks for any help,

ianc
ianc is offline   Reply With Quote