Error checking with regex