add setRegex method as described in the docs