From ae1c9a509bc8b16d263dd117a9ec397fa7db7a2e Mon Sep 17 00:00:00 2001 From: coderkun Date: Mon, 5 May 2014 11:15:53 +0200 Subject: [PATCH] Questtype ?Textinput?: trim answers for regex matching --- questtypes/textinput/TextinputQuesttypeController.inc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/questtypes/textinput/TextinputQuesttypeController.inc b/questtypes/textinput/TextinputQuesttypeController.inc index aa666790..9d2940a3 100644 --- a/questtypes/textinput/TextinputQuesttypeController.inc +++ b/questtypes/textinput/TextinputQuesttypeController.inc @@ -172,9 +172,16 @@ + /** + * Check if an Character answer matches a Regex. + * + * @param string $regex Regex to match against + * @param string $answer Character answer to match + * @return boolean Whether answer matches Regex or not + */ private function isMatching($regex, $answer) { - $score = preg_match($regex, $answer); + $score = preg_match($regex, trim($answer)); return ($score !== false && $score > 0);