Added helper function for parsing regular expressions.