Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 07-07-2016, 02:34 AM   #1
msciwoj
Junior Member
msciwoj began at the beginning.
 
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)$','')'}
but I'm getting:

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)$","")'}
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 )


What I'am doing wrong?
msciwoj is offline   Reply With Quote
Old 07-07-2016, 09:29 AM   #2
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85397180
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
eschwartz is offline   Reply With Quote
Advert
Old 07-07-2016, 02:12 PM   #3
msciwoj
Junior Member
msciwoj began at the beginning.
 
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)$","")'}
msciwoj is offline   Reply With Quote
Old 07-07-2016, 03:55 PM   #4
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,806
Karma: 7029971
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)$','')
chaley is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 02:21 PM.


MobileRead.com is a privately owned, operated and funded community.