use compiled regexs (restricting inputs) in KWS

* just use regex.pattern instead