Fix case insensitive regex matching

Close #794