hacking impl. of regex