View Single Post
Old 04-01-2021, 04:41 PM   #4
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,731
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by 1v4n0 View Post
Thank you. And what would the regex be? (just so I don't have to wade through the whole user manual )
In the Calibre Editor, press CTRL+F, select the regex function mode, click Create/edit, paste the following code into the editor,

Code:
def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):
    return str(len(match.group()))
give the function a name, e.g. CharLen and enter (A+) as the search expression.

If your text contains AAA and AAAA, they should be replaced with 3 and 4.
Doitsu is offline   Reply With Quote