![]() |
#1 |
Junior Member
![]() Posts: 4
Karma: 10
Join Date: Apr 2016
Device: Kindle Voyage
|
how to use re() function in Template Program Mode?
As per subject, knowing that in TPM all strings used as arguments must be enclosed in quotes, I'm trying:
Code:
{publisher:'re(' (Media|Publishing|Press)$','')'} calibre, version 2.61.0 ERROR: Invalid template: <p>The template {publisher:'re(' (Media|Publishing - ebooks Account)$','')'} - {title:re(: ,:)} ({:'format_date(raw_field('pubdate'),'yyyy MMM')}) {identifiers:'ifempty(select($, 'isbn'), select($, 'asin'))'} is invalid:<br>Formatter: incorrect number of arguments for function re near ) same with double quotes: Code:
{publisher:'re(" (Media|Publishing - ebooks Account)$","")'} ERROR: Invalid template: <p>The template {publisher:'re(" (Media|Publishing - ebooks Account)$","")'} - {title:re(: ,:)} ({:'format_date(raw_field('pubdate'),'yyyy MMM')}) {identifiers:'ifempty(select($, 'isbn'), select($, 'asin'))'} is invalid:<br>Formatter: incorrect number of arguments for function re near ) What I'am doing wrong? |
![]() |
![]() |
![]() |
#2 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Template program mode also requires specifying the initial argument for the function.
See: http://manual.calibre-ebook.com/temp...e-program-mode |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() Posts: 4
Karma: 10
Join Date: Apr 2016
Device: Kindle Voyage
|
Doesn't work either
![]() single quotes: {publisher:'re($,' (Media|Publishing - ebooks Account|Press)$','')'} calibre, version 2.61.0 ERROR: Invalid template: <p>The template {publisher:'re($,' (Media|Publishing - ebooks Account|Press)$','')'} is invalid:<br>Invalid conversion specification double quotes: {publisher:'re($," (Media|Publishing - ebooks Account|Press)$","")'} calibre, version 2.61.0 ERROR: Invalid template: <p>The template {publisher:'re($," (Media|Publishing - ebooks Account|Press)$","")'} is invalid:<br>Invalid conversion specification Up to two alternations work seem to work, Bizarre!: {publisher:'re($," (Media|Publishing - ebooks Account)$","")'} |
![]() |
![]() |
![]() |
#4 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,354
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Turns out that having two "|" characters in a TPM template triggers the prefix and suffix processing. This is arguably a bug, but it isn't one I am going to try to fix.
Use GPM instead. It makes no assumptions about the meaning of | and {} Code:
program: re(field('publisher'),' (Media|Publishing - ebooks Account|Press)$','') |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
function mode: surprising count | roger64 | Editor | 7 | 06-18-2016 02:12 PM |
Function mode: Feature Request | jbacelar | Editor | 2 | 11-22-2014 02:36 AM |
General Program Template | StevieCoops | Library Management | 3 | 09-30-2013 11:02 PM |
Date formatting/template program mode | bookworm2000 | Library Management | 4 | 12-28-2012 04:41 PM |
Does anyone use "general program mode" template functions? | chaley | Library Management | 0 | 08-16-2011 11:54 AM |