def pattern_input(self, question, message='<STR_LIT>', pattern='<STR_LIT>', default='<STR_LIT>',required=True):
result = '<STR_LIT>'<EOL>requiredFlag = True<EOL>while (not result and requiredFlag):<EOL><INDENT>result = input('<STR_LIT>' % question)<EOL>if result and pattern and not re.match(pattern, result):<EOL><INDENT>self.stdout.write(self.style.ERROR(message))<EOL>result = '<STR_LIT>'<EOL><DEDENT>elif not result and default:<EOL><INDENT>return default<EOL><DEDENT>elif not result and required:<EOL><INDENT>self.stdout.write(self.style.ERROR('<STR_LIT>'))<EOL><DEDENT>elif not required:<EOL><INDENT>requiredFlag = False<EOL><DEDENT><DEDENT>return result<EOL>
Method for input disallowing special characters, with optionally
specifiable regex pattern and error message.