Thread: Titles
View Single Post
Old 04-04-2025, 02:36 PM   #4
fidvo
Addict
fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.
 
Posts: 309
Karma: 1645952
Join Date: Jun 2012
Device: none
Quote:
Originally Posted by gianni_1 View Post
Yes, I would really like to know the meaning, thanks.
^ : Only match from the start of the text. That way, if you start with a title with 4 dashes it won't match twice because the second pair doesn't come at the beginning.
. : Match any character.
* : Match zero or more. So .* matches any number of any character.
? : Make the preceding a non-greedy match. Otherwise, a dash would itself count as "any character" and therefore the regex would match the last two dashes instead of the first two.
\- : Escapes the dash. Dashes have meaning in regular expressions, so escaping it causes it to be treated as a literal dash.

So using the first title from your thumbnail:

^.*?\- matches Al Kalak Mateo - (any number of any character followed by a dash)
The second .*?\- matches 2024 - (same reason)
Because you're replacing the matched text with nothing, the result is everything else:

Fuoco e fiamme: Storia e geografia dellInferno

Note that I didn't include anything to deal with leftover white space (i.e. the space after the second dash) because Calibre automatically trims white space from the beginning of titles.
fidvo is offline   Reply With Quote