View Single Post
Old 10-02-2023, 10:19 PM   #957
sardonica
Junior Member
sardonica began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Oct 2023
Device: kobo libra 2
Keep only initial 2 characters of each word

I'm sure this is the easiest solution ever but the Calibre Template Language guide is going entirely over my head. I'd like to understand how to modify the code below to include the first 2 (rather than 1) characters of each word in text string. But, if the text string is just one word, I'd like to include the first 4 characters. I thought the "\1" indicated the number of characters but was definitely wrong on that front

{#textstring:re([\s]?([^\s])[^\s]+(\s|$),\1)}

Example:
Lord of the Rings --> LoofthRi
Villains --> Vill

Thank you in advance!
sardonica is offline   Reply With Quote