View Single Post
Old 10-18-2015, 06:45 AM   #10
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,435
Karma: 27757438
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Use the \b operator to match word boundaries, like this

\bcolor\b

And you can create a single saved search to do all your replacing if you are willing to use function mode, something like this

\bcolor|odor|vapor|...\b

and define a function to do the actual replacement,

http://manual.calibre-ebook.com/function_mode.html

Code:
def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):
   return {'color':'colour', 'odor':odour', 'vapor':vapour'}.get(match.group(), match.group())
kovidgoyal is offline   Reply With Quote