View Single Post
Old 01-01-2013, 09:47 PM   #1
bookworm2000
Member
bookworm2000 is a jewel in the roughbookworm2000 is a jewel in the roughbookworm2000 is a jewel in the roughbookworm2000 is a jewel in the roughbookworm2000 is a jewel in the roughbookworm2000 is a jewel in the roughbookworm2000 is a jewel in the roughbookworm2000 is a jewel in the roughbookworm2000 is a jewel in the roughbookworm2000 is a jewel in the roughbookworm2000 is a jewel in the rough
 
Posts: 14
Karma: 7220
Join Date: Dec 2012
Device: Kindle 4NT, Android
Template/Regular Expression Trouble

Hi,

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...

Code:
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

Code:
	[A-IĀ-IJ]
That works fine in the Edit template window, the calculated Template value is "Authors A-I".

But the colums and tag browser show it under "other".

I also tried unicode:

Code:
	[A-I\u0100-\u0132]
but it's still an incorrect result.

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
bookworm2000 is offline   Reply With Quote