One useful pattern: assume you want to change the case of an entire field. Please see the All about using regular expressions in calibre for more information on backreferences. For example, given the same example as above, a bad cat, a search expression a (…) (…), and a replace expression a \2 \1, the result will be a cat bad. where n is an integer that refers to the n’th parenthesized group in the search expression. The third and most important is that the replace string can make reference to parts of the search string by using backreferences. The second is that functions apply to the replacement string, not to the entire field.
The first is that functions are applied to the parts of the string matched by the search string, not the entire field. Regular expression mode has some differences from character mode, beyond (of course) using regular expressions. In the majority of cases the book test boxes will be sufficient, but it is possible that there is a case you want to check that isn’t shown in these boxes. The Your test box is provided for you to enter text to check that search/replace is doing what you want. Title case – capitalize each word in the result. Upper case – change all the characters in the field to upper case Lower case – change all the characters in the field to lower case You can have calibre change the case of the result (information after the replace has happened) by choosing one of the functions from the Apply function after replace box. If you want the search to ignore upper/lowercase differences, uncheck the Case sensitive box. For example, if your tags contain Horror, Scary, the search expression r, will not match anything because the expression will first be applied to Horror and then to Scary. If the field you are searching on is a multiple field like tags, then each tag is treated separately. If you search for a to be replaced with HELLO, then the result will be HELLO bHELLOd cHELLOt. For example, assume the field being searched contains a bad cat. Each occurrence of the search characters in the field will be replaced. Character match will look in the Search field you choose for the characters you type in the search for box and replace those characters with what you type in the replace with box. For more on regular expressions, see All about using regular expressions in calibre.Īs noted above, there are two search and replace modes: character match and regular expression. By default it uses a simple text search and replace, but it also support regular expressions. The Edit metadata for many books dialog allows you to perform arbitrarily powerful search and replace operations on the selected books.