View Single Post
Old 01-16-2011, 03:52 AM   #9
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,740
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Here is a solution. It works on the example you gave me.
Code:
program:
	comments = field('comments');
	contains(	comments,
				'(?i).*?last page read: location', 
				cmp(re(	comments,
						'(?is).*last page read: location \d+ \((\d+)%\).*', 
						'\1'),
					94,
					'No',
					'No',
					'Yes'),
				'')
The right way to solve this problem is to write a user-defined formatter function in python, something that became possible in 0.7.40. The reason: it is much easier to deal with 'unexpected situations' when writing in python. For example, the above code absolutely depends on the characters in the parenthesis being digits. If they are not, then ugly 'exception' messages get printed.
chaley is offline   Reply With Quote