Thread: Capitalize
View Single Post
Old 03-30-2014, 06:47 AM   #5
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,463
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by eschwartz View Post
Because that isn't title case. You can use a regex on the titles, though. Can't remember what the regex is to capitalize a letter at the moment.
Python regexps don't have replacement target processing like the ones in VI. However, there is a way to do it using calibre's post processing on search/replace. The idea is to find each word one by one then capitalize that word. 'Twas a bit of a challenge to work it out. You can see it in the screen capture of the bulk metadata search and replace I used. The text of the regexp in that capture is
Code:
((?<=^)|(?<= ))(.*?)(?= |$)
which means look-behind for a space or the beginning of the text, then match as little as possible until a look-ahead for a space or the end of the text succeeds.
Attached Thumbnails
Click image for larger version

Name:	Clipboard02.png
Views:	382
Size:	57.9 KB
ID:	121016  
chaley is offline   Reply With Quote