View Single Post
Old 01-15-2011, 07:38 AM   #5
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,703
Karma: 6658935
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
The problem might be related to the expression failing if there isn't an annotation in the comments.

Try
Code:
{comments:'contains($, '(?i).*?last page read: location \(\d+\)', re($, '(?i).*?last page read: location \((\d+)\).*', '\1'), '')'}
This checks to see of the regular expression
Code:
(?i).*?last page read: location \(\d+\)
matches the comments. If it does, then it calls 're' to slice out the number. If it does not, then it returns '' (the empty string).

The (?i) does indeed mean ignore case.

The string test for 'last page read: location \(\d+\)' must match exactly. No extra spaces, no extra punctuation, no variants in spelling, and parenthesis around the numbers.

Ahh... looking at your original example, I note the % character. I didn't account for that. Try
Code:
{comments:'contains($, '(?i).*?last page read: location \(\d+%\)', re($, '(?i).*?last page read: location \((\d+)%\).*', '\1'), '')'}
chaley is offline   Reply With Quote