Format user input to match a specified pattern