A better way to create regular expressions