Skip to main content

Regular expressions

This section is under construction.

With regular expressions, the system can compare the answer a student submits to predefined answers in the feedback. The student then receives the feedback specific for his answer. The comparison is performed with the following 'rule-set':

^: start of the answer

$: end of the answer

.: any character

[]: a single character within the brackets

[^]: any character that is not in the brackets

^: first character

$: last character

?: zero or none of the preceding element

+: One or more of the preceding element

*: Zero or more of the preceding element

{x}: repeats the character exactly x times

{x,y}: repeats the preceding character x to y times

|: match before or after


To determine if a given answer is a valid number you can use: pattern="^[+-]?[0-9]+(\[.,][0-9]+)?([eE][+-]?[0-9]+)?$" 

Regular expression        Possible student answers

ab ab

[ab] a and b

External links

Wikipedia page

Tutorial website