Quote:
Originally Posted by sardonica
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!
|
Code:
{series:'contains($, ' ', re($,'\s*(\S{{,2}})\S*(?:\s|$)','\1'), re($, '^(\S{{,4}}).*$', '\1'))'}