I'd forgotten that searches are case insensitive, so the regexp search doesn't work, sorry.
Getting and setting custom column values is pretty easy:
Code:
existing=db.get_custom(book_id,label=label,index_is_id=True)
db.set_custom(book_id, value, label=label, commit=True)
Where label is the # name, like #wordcount, or whatever you set it to.
(added) And, of course, you can use the custom column for the search instead of the regexps.