View Single Post
Old 01-16-2011, 02:37 AM   #6
pchrist7
Addict
pchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animals
 
pchrist7's Avatar
 
Posts: 385
Karma: 6514
Join Date: Aug 2010
Location: Denmark
Device: Kindle 3 3G+Wifi
That's not either I'm afraid

Quote:
Originally Posted by chaley View Post
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'), '')'}
Hi chaley
Again thanks for the effort so far !
tried your last code, but column is blank
Testing on a book with just the annotations in comments, the HTML of the comments are as follows:

<div class="user_annotations">
<span style="font-weight:bold">
10-12-2010<br>Last Page Read: Location 4862 (99%)
</span>
<br></div>

This is over my head, I'm afraid.
Hope you're still willing to look at this.
pchrist7 is offline   Reply With Quote