|01-01-2013, 09:47 PM||#1|
Join Date: Dec 2012
Device: Kindle 4, Kindle for Android
Template/Regular Expression Trouble
I'm using a custom column to work with the Kindle Collections plugin. It collects author names in three groups ("A-I", "J-Q" and "S-Z"). A fourth ("other") is reserved for authors who might call themselves something like 123foo or $bar.
The following code worked fine so far...
program: author_first_letter = substr(field('author_sort'), 0, 1); group = switch(author_first_letter, '[A-I]', 'A-I', '[J-R]', 'J-R', '[S-Z]', 'S-Z', 'other'); strcat('Authors ', group)
...until Karel Čapek came along.
His books should be found in the "A-I" collection but are listed under "other". So I expanded the regular expression to
But the colums and tag browser show it under "other".
I also tried unicode:
Being both 1) new to the calibre template language and 2) a regular-expression-avoider-whenever-I-can I assume that I made a mistake... but what puzzles me is that the Template value of the Edit template window shows the expected "Authors A-I" (at least in the first case, without unicode notation).
Could this be a bug in Calibre?
Last edited by bookworm2000; 01-01-2013 at 09:54 PM. Reason: typo
|01-02-2013, 05:31 AM||#2|
Join Date: Jan 2010
Device: Sony PRS-300, HTC WM6.5, Samsung Galaxy Nexus, HTC Sensation
You found a strange bug in calibre that has been lurking for many months. Character classes are not processed in unicode in compiled template functions, but *are* in interpreted template functions. Functions are interpreted when using the template editor. They are compiled for performance when used in composite columns.
I have submitted a fix that should be in the next release. In the meantime you can work around the problem by changing the tweak "Compile General Program Mode templates to Python" to False.
|Thread Tools||Search this Thread|
|Thread||Thread Starter||Forum||Replies||Last Post|
|More than 3 regular expression?||james968||Conversion||1||04-04-2012 05:39 AM|
|Regular Expression Help||Azhad||Calibre||86||09-27-2011 02:37 PM|
|Regular Expression Help||smartmart||Calibre||5||10-17-2010 05:19 AM|
|Help!! Having trouble with regular expression||Partzz||Calibre||2||09-14-2010 12:32 PM|
|Help with the regular expression||Dysonco||Calibre||9||03-22-2010 10:45 PM|