Fix bugs in regex