fix bug in regex function