View Single Post
Old 03-15-2015, 09:55 AM   #2
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: 12,475
Karma: 8025702
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
You wrote a Single Function Mode template. In that mode you do not quote strings. However, because the parameters include parenthesis, you should probably use Template Program Mode or General Program Mode.

The pattern must match the entire string so that the replacement replaces it all. In addition because the string is multiline you must tell re that the '.' character can match a newline. Taking these into account, your template in GPM would be
Code:
program:
	re(field('#comment'), '(?ms).*Lable: (.*?)\n.*' , '\1')
As for testing, there are two ways. The first is to edit the template for the column built ... directly on the spreadsheet. Click in any cell in that column and press F2 or whatever means 'Edit' on your system. The second is to use the template tester, which lets you evaluate templates for a given book. You can add the template tester to the context menu or to the tool bar in calibre's preferences / Toolbar
chaley is offline   Reply With Quote