fix regular expression matching, hopefully once and for all.