added support for format regexes with flags