cw.lua.in: fix anchor matching in regexes, and fix off-by-one errors.