tweaked for support for regex