pull out some common functions. wrap coffee compiled stuff in a function call. escape string for regexp.