Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions docs/labs/input2.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,6 @@
<script src="input2.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">

<!-- Sample expected answer -->
<script id="expected0" type="plain/text">
query('id').isLength({max:80}).
matches( /^[A-Z]{2}-[0-9]+-[0-9]+$/ ),
</script>

<!-- Full pattern of correct answer.
This specific example is a worst case; we're using
using regex to check on a regex, requiring a large number of escapes.
This pattern is very generous, allowing
constructs like \d for digits and {1,} instead of +. -->
<script id="correct0" type="plain/text">
\s* query \( ('id'|"id"|`id`) \)
\. isLength \( \{ max: 80 ,? \} \)
\. matches \(
\/\^
\[A-Z\](\{2\}|\[A-Z\])
-
(\[0-9\]|\\d)(\+|\{1,\})
-
(\[0-9\]|\\d)(\+|\{1,\})\$\/
\) , \s*
</script>

</head>
<body>
<!-- For GitHub Pages formatting: -->
Expand Down
30 changes: 25 additions & 5 deletions docs/labs/input2.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ info =
},
{
present: "(islength|Islength|IsLength|ISLENGTH)",
text: "JavaScript is case-sensitive. Use isLength instead of the case you have.\n"
text: "JavaScript is case-sensitive. Use isLength instead of the case you have."
},
{
absent: "isLength",
Expand Down Expand Up @@ -47,13 +47,30 @@ info =
},
{
present: String.raw`matches \( /.*(\[0-9\]|\d)\*`,
text: "You need to match one or more digits; * allows 0 or more. A + would be better suited for this task.\n"
text: "You need to match one or more digits; * allows 0 or more. A + would be better suited for this task."
},
{
present: String.raw`\s*, , $`,
text: "You have two commas at the end. Use only one. You may need to scroll or increase the text area to see both of them.\n"
text: "You have two commas at the end. Use only one. You may need to scroll or increase the text area to see both of them."
}
],
expected: [
String.raw` query('id').isLength({max:80}).
matches( /^[A-Z]{2}-[0-9]+-[0-9]+$/ ),`,
],
// Full pattern of correct answer.
// This specific example is a worst case; we're using
// a regex to check on a regex, requiring a large number of escapes.
correct: [
// This pattern is very generous, allowing
// constructs like \d for digits and {1,} instead of +.
String.raw`\s*
query \( ('id'|"id"|${BACKQUOTE}id${BACKQUOTE}) \)
\. isLength \( \{ max: 80 ,? \} \)
\. matches \(
\/\^\[A-Z\](\{2\}|\[A-Z\])-(\[0-9\]|\\d)(\+|\{1,\})-(\[0-9\]|\\d)(\+|\{1,\})\$\/
\) , \s*`
],
successes: [
[
"query(`id`).isLength( {max:80}).matches(/^[A-Z]{2}-\\d+-[0-9]+$/),"
Expand All @@ -74,6 +91,9 @@ info =
],
[
"query(`id`).isLength( {max:80}).matches(/^[A-Z]{2}-\\d+-[0-9]+$/)"
]
]
],
[
"query(`id`).isLength( {max:80}).matches(/^[A-Z]{2}- \\d+-[0-9]+$/),"
],
],
}