Fixed bug in regex pattern matching