View Single Post
Old 03-15-2015, 07:21 AM   #1
rcross
Junior Member
rcross began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Mar 2015
Device: kindle, ipad, desktop, multiple
Using regex for substring of comments field

I've searched around quite a bit and tried lots of things, so hopefully i'm just missing something minor.

I have some data in the comments field that I would like to display in a custom column, but I can't seem to get it working;

In the comments fields are things Like:
Code:
Lable: Some Info Here
Lable2: More info
that might be on 2 lines

[optional]general descriptive text
And being the comments field, sometimes it has html characters and sometimes not.

What I think I should be able to do is create a custom column of type "custom built from other columns" and using a template

Code:
{comments:re( 'Label: (\w*)' , '\1')}

Which should give me the output of "Some Info Here" in the column, but what I'm getting is the whole comments field. I've tried many different variations, and anytime I don't get an error, I get the same result of the whole comments field in the column.

I've been able to get {comments:substr(10,25)} to work, and I also replicate the same issue trying to apply re() on other columns like title. The closest I could find is this thread https://www.mobileread.com/forums/sho...d.php?t=245895 where the very last post has someone trying to do something similar for a version string they've stored in the comments field, but with no answer.

As a side note - is there any way to test/debug these things without requiring a restart of calibre everytime?

Thanks!
rcross is offline   Reply With Quote