---
title: Regular Expression Short Text Question
description: Regular expression question type
---

[Skip to content](https://support.atomicjolt.com/knowledgebase/regular-expression-short-text-question#main-content)

English

Show submenu for translations

[File a Support Ticket](https://support.atomicjolt.com/knowledgebase/kb-tickets/new?hsLang=en) [Customer Portal](https://support.atomicjolt.com/tickets-view?hsLang=en)

![Atomic Jolt Logo Horiz Small](https://support.atomicjolt.com/hs-fs/hubfs/Atomic%20Jolt%20Logo%20Horiz%20Small.png?width=260&height=95&name=Atomic%20Jolt%20Logo%20Horiz%20Small.png)

- [Release Notes Sign Up](https://share.hsforms.com/1iZCRfUF5QHeWYwcLC3bwEAdk6gc)

Open main navigation

Close main navigation

- [Release Notes Sign Up](https://share.hsforms.com/1iZCRfUF5QHeWYwcLC3bwEAdk6gc)
- English
  
  Show submenu for translations
- [File a Support Ticket](https://support.atomicjolt.com/knowledgebase/kb-tickets/new)
- [Customer Portal](https://support.atomicjolt.com/tickets-view)

 How can we help you?

- There are no suggestions because the search field is empty.

1. [Atomic Jolt Knowledge Base](https://support.atomicjolt.com/knowledgebase?hsLang=en)
2. [Atomic Assessments](https://support.atomicjolt.com/knowledgebase/atomic-assessments?hsLang=en)
3. [Question Types](https://support.atomicjolt.com/knowledgebase/atomic-assessments?hsLang=en#question-types)

# Regular Expression Short Text Question

## The Regular expression short text question is a short-answer question that Atomic Assessments grades automatically by checking the student's typed answer against one or more patterns you write.

- **What students see:** a single text box (or a multi-line box), just like a standard short-answer question.
- **What you write:** one correct answer plus any number of alternate answers. Each answer can be plain text or a regular expression (a pattern that describes many acceptable answers at once).
- **What happens on submit:** the response is cleaned up, compared against each answer, and given the score and feedback of the answer it matches.
- **Where to find it:** in the question type list under **Write & Speak**, named **Regular expression short text**.

### **Why use it**

Use it when a question has one right idea but many acceptable ways to type it, and listing every variation as an alternate answer would be impractical. The standard Short text question checks for an exact phrase or a phrase contained in the answer. A regular expression describes a whole family of answers in one line.

| Situation | Standard Short text | Regular expression short text |
| --- | --- | --- |
| **Spelling variants (color / colour, gray / grey)** | One alternate per spelling | One pattern: colou?r |
| **Optional words ("the mitochondria" / "mitochondria")** | One alternate per version | One pattern: (the )?mitochondria |
| **Numbers with rounding or optional units ("9.8", "9.81 m/s^2")** | Not practical | One pattern covers every format |
| **Code, commands, or syntax with flexible spacing or names** | Not practical | Pattern accepts any valid form |
| **Formatted answers (dates, IDs, chemical formulas)** | Not practical | Pattern checks the format |
| **Partial credit for close answers** | Possible with alternates | Separate patterns, each with its own points and feedback |

Good fits:

- **Computer science and programming:** short code lines, command syntax, or assembly instructions where spacing and naming can vary.
- **STEM:** numeric answers with accepted rounding, units, or notation.
- **Languages and humanities:** accepted spellings, accents, or optional words.
- **Targeted feedback:** a pattern that catches a common mistake and returns feedback that explains it.

If you only need two or three acceptable answers, the standard Short text question is simpler and easier for co-authors to maintain.

### **How it works**

Each time a response is scored, Atomic Assessments runs these steps.

1. **Clean up the response.** Leading and trailing spaces and blank lines are removed. Tabs become spaces, and runs of spaces become one space. Any characters listed in **Additional characters to convert to whitespace** are turned into spaces.
2. **Read each answer in order.** The **Correct** answer is checked first, then **Alternate 1**, **Alternate 2**, and so on.
   
     1. **Regular expression on** (the default): the Value is treated as a pattern.
     2. **Regular expression off:** the Value is treated as plain text. Symbols like . or ? mean only themselves.
3. **Apply the Allow rule.** 
     1. **Exact match:** the pattern must match the whole response. If your pattern starts with ^ or ends with $, your anchors are used instead.
     2. **Any text containing:** the pattern only needs to appear somewhere in the response as whole words. cat matches "the cat sat" but not "category".
4. **Apply case sensitivity.**Matching ignores capitalization unless **Case sensitive** is on.
5. **Award the match.** The first answer that matches sets the score and the feedback. A response that matches nothing scores 0. A blank response always scores 0.

A **catch-all** answer is the exception to the order rule. An answer whose Value is exactly .\* or \* is always checked last, wherever it sits in the list. Use it to give feedback (and, if you want, a score) to any response that matched none of your patterns.

### **What students see**

1. **While answering:** a text box with spell check turned off. The **Character limit** (default 50) caps what they can type.
2. **Check answer** (if enabled): the box is marked correct or incorrect, and any feedback on the matched answer is shown.
3. **Correct answer shown in review:** the text in the **Correct answer** field. If that field is blank and the Correct answer is plain text, its Value is shown. If it is blank and the Correct answer is a pattern, nothing is shown, so students never see raw regex.

### **Creating a question**

1. **Add the question.** In an item, add a new question and choose **Write & Speak \> Regular expression short text**.
2. **Write the question text.** Tell students the expected format if it matters (for example, "Round to two decimal places" or "Use register names like R1").
3. **Set the Correct answer.** Under **Set correct answer(s)**, fill in: 
     1. **Value:** the pattern (or plain text) that earns full credit.
     2. **Point(s):** the score for a match.
     3. **Allow:** Exact match or Any text containing.
     4. **Regular expression:** leave on for a pattern; turn off for plain text.
     5. **Feedback** (optional): what the student sees when their response matches this answer.
4. **Add alternate responses.** Use **Alternate responses** for other accepted patterns, partial-credit patterns, or common mistakes. Each alternate has its own Value, Point(s), Allow, Regular expression, and Feedback.
5. **Order the answers.** Put your highest-scoring answer first. The first match wins, so a broad pattern placed early can block a more specific one below it.
6. **Add a catch-all (optional).** Add an alternate with the Value .\*, 0 points, and feedback such as "Check your formatting and try again."
7. **Set the matching options.** Turn on **Case sensitive** if capitalization matters. Use **Additional characters to convert to whitespace** for punctuation you want ignored (for example, ,;).
8. **Fill in Correct answer.** Enter a clean model answer (not the pattern). This is what students see when correct answers are shown.
9. **Set the layout.** Choose **Input style** (single line or multi-line), **Number of input lines**, **Character limit** (up to 250), and an optional **Placeholder**.
10. **Turn on Check answer (optional).** Enable **Check answer button** and set **Check answer attempts** (0 = unlimited) for practice questions.
11. **Test it in preview.** Type every answer you expect, plus likely wrong ones, and confirm each gets the right score and feedback. Use the testing checklist below.

### **Pattern examples**

Every example below uses **Allow: Exact match**, **Regular expression** on, and **Case sensitive** off.

| Goal | Value | Accepts | Rejects |
| --- | --- | --- | --- |
| **Either spelling** | colou?r | color, Colour | colors |
| **Either vowel** | gr\[ae\]y | gray, grey | greay |
| **Optional word** | (the )?mitochondria | mitochondria, The mitochondria | mitochondrion |
| **One of several answers** | (paris\|lyon) | Paris, Lyon | Marseille |
| **A whole number, positive or negative** | -?\\d+ | 42, -7 | 4.2 |
| **A decimal with extra precision allowed** | 3\\.14\\d\* | 3.14, 3.14159 | 3.1 |
| **A number with optional units** | 9\\.8\\d\*( ?m/s\\^?2)? | 9.8, 9.81 m/s^2, 9.81m/s2 | 98 |
| **Code with flexible spacing and register** | mov r\[0-7\], ?#?\\d+ | MOV R1, #5; mov r1,5 | mov r8, 5 |
| **A required format** | \\d{4}-\\d{2}-\\d{2} | 2026-10-22 | 10/22/2026 |

### **Symbols you will use most**

| Symbol | Meaning | Example |
| --- | --- | --- |
| **?** | The item before it is optional | colou?r |
| **\|** | Or | cat\|dog |
| **( )** | Groups items together | (the )?cell |
| **\[ \]** | Any one character from the set | \[ae\], \[0-7\] |
| **\\d** | Any digit | \\d\\d = two digits |
| **\* / +** | Zero or more / one or more of the item before it | \\d+ |
| **{n}** | Exactly n of the item before it | \\d{4} |
| **\\.** | A literal period (a plain . means any character) | 3\\.5 |
| **^ / $** | Start / end of the response | ^mov |

Patterns use standard JavaScript regular expression syntax. For anything not covered here, any JavaScript regex reference applies.

### **Scoring**

1. **Score:** the Point(s) of the first matching answer. No match or a blank response = 0.
2. **Maximum score:** the highest Point(s) value across the Correct answer and all alternates.
3. **Partial credit:** give an alternate fewer points than the Correct answer (for example, 1 of 2 points for a right value with the wrong units).
4. **Scoring type:** Exact match is the only option. Partial credit comes from alternates, not from a scoring type.
5. **Penalty point(s) and Minimum score if attempted:** these appear in the editor but are not currently applied by this question type. Don't rely on them.
6. **Unscored/Practice usage:** removes scoring from the question.
7. **Enable auto scoring off:** the question is graded by hand instead of by pattern.

### **Tips and common mistakes**

| Mistake | What happens | Fix |
| --- | --- | --- |
| **Leaving Regular expression on for a plain answer** | The answer 3.5 also accepts "305", because . means any character. | Turn the toggle off for plain text, or write 3\\.5. |
| **Anchoring only one end** | With ^ but no $, the other end is left open: ^mov accepts "move everything". | Anchor both ends or neither. Exact match already matches the whole response. |
| **Using an ignored character in a pattern** | If , is ignored, the response "a,b" is checked as "a b", so a pattern with a comma never matches. | Write the pattern with a space where the ignored character would be. |
| **A typo in the pattern** | An unclosed ( gives no error; that answer simply never matches. | Test every answer in preview. |
| **A broad pattern listed first** | The first match wins, so later, more specific answers never apply. | List the full-credit answer first, then partial-credit and mistake patterns. |
| **Character limit too short for code** | Students can't type past 50 characters by default. | Raise the Character limit (maximum 250). |
| **Correct answer field left blank** | Students reviewing a pattern-based question see no correct answer. | Enter a clean model answer. |

Extra spaces don't matter: double spaces in a response are reduced to one, so you don't need to allow for them.

- [Atomic Jolt Customer FAQs](https://support.atomicjolt.com/knowledgebase/atomic-jolt-customer-faqs?hsLang=en)
- [Atomic Assessments](https://support.atomicjolt.com/knowledgebase/atomic-assessments?hsLang=en#main-content)

    - [Release Notes](https://support.atomicjolt.com/knowledgebase/atomic-assessments?hsLang=en#release-notes)
    - [Authoring Assessments](https://support.atomicjolt.com/knowledgebase/atomic-assessments?hsLang=en#authoring-assessments)
    - [For Nursing](https://support.atomicjolt.com/knowledgebase/atomic-assessments?hsLang=en#for-nursing)
    - [Content Management](https://support.atomicjolt.com/knowledgebase/atomic-assessments?hsLang=en#content-management)
    - [Question Types](https://support.atomicjolt.com/knowledgebase/atomic-assessments?hsLang=en#question-types)
    - [Grading & Feedback](https://support.atomicjolt.com/knowledgebase/atomic-assessments?hsLang=en#grading-feedback)
    - [Reports](https://support.atomicjolt.com/knowledgebase/atomic-assessments?hsLang=en#reports)
    - [Import and Export](https://support.atomicjolt.com/knowledgebase/atomic-assessments?hsLang=en#import-and-export)
    - [Advanced Features](https://support.atomicjolt.com/knowledgebase/atomic-assessments?hsLang=en#advanced-features)
    - [Proctoring](https://support.atomicjolt.com/knowledgebase/atomic-assessments?hsLang=en#proctoring)
    - [Installation Guides](https://support.atomicjolt.com/knowledgebase/atomic-assessments?hsLang=en#installation-guides)
    - [FAQ for Atomic Assessments](https://support.atomicjolt.com/knowledgebase/atomic-assessments?hsLang=en#faq-for-atomic-assessments)
    - [Adaptive Assessments](https://support.atomicjolt.com/knowledgebase/atomic-assessments?hsLang=en#adaptive-assessments)
    - [Learning Standards](https://support.atomicjolt.com/knowledgebase/atomic-assessments?hsLang=en#learning-standards)
    - [Brightspace](https://support.atomicjolt.com/knowledgebase/atomic-assessments?hsLang=en#brightspace)
    - [Canvas](https://support.atomicjolt.com/knowledgebase/atomic-assessments?hsLang=en#canvas)
    - [Publishers](https://support.atomicjolt.com/knowledgebase/atomic-assessments?hsLang=en#publishers)
    - [Admin Features](https://support.atomicjolt.com/knowledgebase/atomic-assessments?hsLang=en#admin-features)
- [Atomic Search](https://support.atomicjolt.com/knowledgebase/atomic-search?hsLang=en#main-content)

    - [FAQs](https://support.atomicjolt.com/knowledgebase/atomic-search?hsLang=en#faqs)
    - [Using Search](https://support.atomicjolt.com/knowledgebase/atomic-search?hsLang=en#using-search)
    - [Admin Features](https://support.atomicjolt.com/knowledgebase/atomic-search?hsLang=en#admin-features)
    - [Content Indexing](https://support.atomicjolt.com/knowledgebase/atomic-search?hsLang=en#content-indexing)
    - [Reports & Analytics](https://support.atomicjolt.com/knowledgebase/atomic-search?hsLang=en#reports-analytics)
    - [Brightspace Support](https://support.atomicjolt.com/knowledgebase/atomic-search?hsLang=en#brightspace-support)
    - [Canvas Support](https://support.atomicjolt.com/knowledgebase/atomic-search?hsLang=en#canvas-support)
- [Atomic Journals](https://support.atomicjolt.com/knowledgebase/atomic-journals?hsLang=en#main-content)

    - [Course Authors](https://support.atomicjolt.com/knowledgebase/atomic-journals?hsLang=en#course-authors)
    - [Student Experience](https://support.atomicjolt.com/knowledgebase/atomic-journals?hsLang=en#student-experience)
- [Atomic Polls](https://support.atomicjolt.com/knowledgebase/atomic-polls?hsLang=en#main-content)

    - [Course Authors](https://support.atomicjolt.com/knowledgebase/atomic-polls?hsLang=en#course-authors)
    - [Student Experience](https://support.atomicjolt.com/knowledgebase/atomic-polls?hsLang=en#student-experience)
    - [Course Copy](https://support.atomicjolt.com/knowledgebase/atomic-polls?hsLang=en#course-copy)
- [Atomic Discussions](https://support.atomicjolt.com/knowledgebase/atomic-discussions?hsLang=en#main-content)

    - [Course Authors](https://support.atomicjolt.com/knowledgebase/atomic-discussions?hsLang=en#course-authors)
    - [Student Experience](https://support.atomicjolt.com/knowledgebase/atomic-discussions?hsLang=en#student-experience)
- [Atomic Author](https://support.atomicjolt.com/knowledgebase/atomic-author?hsLang=en)
- [Atomic Socialize](https://support.atomicjolt.com/knowledgebase/atomic-socialize?hsLang=en#main-content)

    - [Release Notes](https://support.atomicjolt.com/knowledgebase/atomic-socialize?hsLang=en#release-notes)
- [Atomic Curriculum Analysis Tool](https://support.atomicjolt.com/knowledgebase/atomic-curriculum-analysis-tool?hsLang=en)

[![Atomic Jolt Logo Horiz Small](https://support.atomicjolt.com/hs-fs/hubfs/Atomic%20Jolt%20Logo%20Horiz%20Small.png?width=164&height=60&name=Atomic%20Jolt%20Logo%20Horiz%20Small.png "Atomic Jolt Logo Horiz Small")](https://www.atomicjolt.com)

Copyright © 2025, Atomic Jolt