View Single Post
Old 09-22-2023, 08:08 AM   #650
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,200
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
Quote:
Originally Posted by theodduck View Post
What would be the best way to remove/replace a list of special characters from titles when saving to disk/sending to device? I'd like to make sure certain characters like colons and commas aren't included and I don't like that Calibre defaults to replacing colons with an underscore. I'm not a coder so I'm kind of fumbling my way through this.

So far I've stumbled through some posts and the documentation to get the following to replace colons with nothing, but I'm not sure how to make it do the same for additional characters
Code:
{title: re(":","")}
Code:
{title: re("[:\,]","")}
The comma here is escaped with a backslash. Some characters don't need to be escaped. For example if you want to also remove characters like semicolons and underscores.

Code:
{title: re("[:\,;_]","")}
Trial and error should guide you into what needs to be escaped and what does not need.
capink is offline   Reply With Quote