
Regular expressions are a way to match patterns of text without listing every option specifically. Regular expressions are used by the Question Library for grading Short Answer and Fill in the Blank question types.
To use regular expressions:
1. Check the box for Regular Expression below the answer box when setting up your question. (See Fill in the Blanks Questions and Short Answer Questions for instructions on question set up.)
2. Write regular expressions, using the symbols shown below, in the question's answer blank.
3. Click Save when done setting up the answer.
Example 1: Fill in the Blanks
Example 2: Short Answer
Character |
Description |
Example |
|---|---|---|
^ |
Matches the position at the beginning of the input string. |
^cat matches any string that begins with cat |
$ |
Matches the position at the end of the input string. |
cat$ matches any string that ends with cat |
* |
Matches the preceding character or subexpression zero or more times. |
be* matches b or be or beeeeeeee |
+ |
Matches the preceding character or subexpression one or more times. |
be+ matches be or bee but not b |
? |
Matches the preceding character or subexpression zero or one time. |
colou?r matches color or colour but not colouur |
( ) |
Parentheses. Creates a substring or item that metacharacters can be applied to. |
a(bee)?t matches at or abeet but not abet |
[ ] |
Brackets. Matches any character in the specified range. |
[1-9] matches any single digit except 0 |