Random Regex Literal Escaping Exercise Generator
Generate random regex literal escaping exercise generator cards from explicit candidate scenarios by importing regex/escape. Validate every candidate, including undrawn ones, and resolve the seed/source once for all draws. Preserves the imported calculator limitations; not a full operational setup plan or guaranteed pedagogical correctness.
Description
Sample supplied literal-pattern scenarios and return their escaped regex forms as practice answers.
Literal regex escaping protects characters that would otherwise have pattern syntax. This exercise pairs selected caller-supplied patterns with the existing escaping tool's output.
When to use this tool
Sample supplied literal-pattern scenarios and return their escaped regex forms as practice answers.
- Prepare the supplied seed, count, withoutReplacement, candidateInputsJson fields for this operation.
- Compare the complete example with the representation used by your own input before carrying the result into another step.
How to use the tool and how it works
- Enter seed, count, withoutReplacement, candidateInputsJson. Use the exact text syntax, units and index conventions explained below.
- Run the tool. If input validation fails, correct the supplied fields before interpreting any result.
- Read result.baseToolId, result.selectedCandidateIndices, result.unusedCandidateIndices, result.exercises. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.
Parse candidateInputsJson as an explicit corpus of complete inputs for the linked base calculator. Initialize the seeded random source and draw count candidate indexes using the replacement choice. Validate every candidate, including undrawn ones, through the base calculator, then execute each selected candidate and return its input and full answer. Also return baseToolId, selectedCandidateIndices in draw order and unusedCandidateIndices in original inventory order.1, 2
| Input field | Meaning and representation | Accepted input |
|---|---|---|
| seed | Reproducibility seed for sampling; keep it with the inventory and output. | Nonblank text, at most 256 UTF-16 code units |
| count | Number of draws; draws select candidate positions. | Integer from 1 to 64; no more than inventory size without replacement |
| withoutReplacement | Explicit choice for without replacement; supply a boolean rather than a text label. | true or false |
| candidateInputsJson | List of complete JSON object input strings for the linked base calculator; every candidate, including unused ones, must be valid. | 1–128 strings, each at most 8,192 code units; total at most 131,072 |
For the JSON text fields, the following decoded structures show the example records before they are serialized into input strings. Keep field names, list nesting and value types as shown.
[
{
"field": "candidateInputsJson",
"decoded": [
{
"pattern": "a.b"
}
]
}
] | Output field | Interpretation |
|---|---|
| result | Object containing the named outputs below. |
| result.baseToolId | Canonical identifier of the calculator used to produce each selected answer. |
| result.selectedCandidateIndices | Zero-based candidate positions in draw order; repeats are possible with replacement. |
| result.unusedCandidateIndices | Original candidate positions never drawn, returned in inventory order. |
| result.exercises | Selected candidate inputs paired with the base calculator’s complete answer objects, in draw order. |
{
"input": {
"seed": "tool.io/batch53",
"count": 1,
"withoutReplacement": true,
"candidateInputsJson": [
"{\"pattern\": \"a.b\"}"
]
},
"output": {
"result": {
"baseToolId": "regex/escape",
"selectedCandidateIndices": [
0
],
"unusedCandidateIndices": [],
"exercises": [
{
"input": {
"pattern": "a.b"
},
"answer": {
"escaped": "a\\.b"
}
}
]
}
}
} Limitations and assumptions
- The answer is an escaped literal pattern, not a general regex repair or an explanation of every regex engine. Candidate scenarios must use the linked tool's exact input fields.
- Seed must be nonblank and at most 256 UTF-16 code units; count is an integer from 1 through 64. Without replacement, count cannot exceed the available inventory. Sampling is reproducible with the same seed and implementation unless an execution context supplies its own random source.
- Every declared top-level field is required and unexpected fields are rejected. Numeric inputs must be finite; ordinary text fields are bounded to 8,192 UTF-16 code units, with tighter operation-specific limits where stated.
- Candidate corpora contain 1–128 JSON object strings, each at most 8,192 code units and at most 131,072 code units in total, with nesting at most sixteen levels and no prototype-control keys. Every candidate is validated by the base tool. Nonfinite results and excessively large serialized outputs are rejected.
- Indexes are zero-based and spans have an exclusive end unless explicitly stated otherwise. A valid false, null or empty-list result is distinct from malformed input.
Alternative or Complementary methods
Use the linked base calculator directly when you need one known answer, and use a sampled corpus for repeatable practice. Retain the candidate inventory, seed and tool/runtime versions with a result; caller-supplied asset tokens need their own provenance and rendering workflow.
References
Similar or alternative tools
- ac power triangle exercise
An AC power triangle relates real, apparent, and reactive power under a stated power factor.
- age calculation exercise
Completed age can be represented as years, remaining months, and remaining days between two dates.