diff --git a/docs/labs/regex0.html b/docs/labs/regex0.html
index 9b078959..af81cb63 100644
--- a/docs/labs/regex0.html
+++ b/docs/labs/regex0.html
@@ -43,14 +43,14 @@
Background
Another rule is that square brackets surround a rule that specifies any of a number of characters. If the square brackets surround just alphanumerics, then the pattern matches any of them. So [brt] matches a single “b”, “r”, or “t”.
Inside the brackets you can include
ranges of symbols separated by dash ("-"), so
-[A-D] will match one character, which can be one A, one B, one C,
-or one D.
-You can do this more than once.
+[A-D] will match one character in that range,
+which can be one A, one B, one C, or one D.
+You can provide more than one range inside brackets.
For example,
the term [A-Za-z] will match one character, which can be
an uppercase Latin letter or a lowercase Latin letter.
-(This text assumes you're not using a long-obsolete character system
-like EBCDIC.)
+(For purposes of our labs we're
+assuming you're not using a long-obsolete character system like EBCDIC.)
If you follow a pattern with “*”, that means
“0 or more times”.
In almost all regex implementations (except POSIX BRE),
diff --git a/docs/labs/regex0.js b/docs/labs/regex0.js
index 51d16328..b2ff8981 100644
--- a/docs/labs/regex0.js
+++ b/docs/labs/regex0.js
@@ -31,6 +31,14 @@ info =
[ "x" ],
],
},
+ {
+ present: String.raw`\[(cat|act)\]`,
+ text: "The pattern '[cat]' or '[act]' matches one latter, a 'c', an 'a', or 't'. That is not what you want.",
+ examples: [
+ [ "[cat]" ],
+ [ "[act]" ],
+ ],
+ },
{
absent: "cat",
text: "The pattern \"cat\" is needed to search for \"cat\".",
@@ -43,7 +51,7 @@ info =
index: 1,
text: "You need to mention A.",
examples: [
- [ "cat", "B" ],
+ [ null, "B" ],
],
},
{
@@ -51,8 +59,8 @@ info =
index: 1,
text: "Use \"A+\" to indicate \"one or more A\". You could also write \"AA*\".",
examples: [
- [ "cat", "A" ],
- [ "cat", "AA" ],
+ [ null, "A" ],
+ [ null, "AA" ],
],
},
{
@@ -60,7 +68,7 @@ info =
index: 1,
text: "You need to mention B.",
examples: [
- [ "cat", "A+" ],
+ [ null, "A+" ],
],
},
{
@@ -69,7 +77,7 @@ info =
index: 1,
text: "Use \"B+\" to indicate \"one or more B\". You could also write \"BB*\".",
examples: [
- [ "cat", "A+B" ],
+ [ null, "A+B" ],
],
},
],
diff --git a/docs/labs/regex1.js b/docs/labs/regex1.js
index c2fca851..7213ab2c 100644
--- a/docs/labs/regex1.js
+++ b/docs/labs/regex1.js
@@ -5,42 +5,42 @@ info =
present: "/",
text: "In JavaScript a constant regular expression is surrounded by forward slashes like /PATTERN/. However, for this exercise we only want the text inside the slashes (the pattern itself).",
examples: [
- [ "/" ]
+ [ "/" ],
],
},
{
present: "[\"'`]",
text: "In this exercise we only want the regular expression pattern itself. There is no need to use any kind of quote mark.",
examples: [
- [ "'" ]
+ [ "'" ],
],
},
{
absent: String.raw`^\^`,
text: "For input validation, start with '^' to indicate a full match.",
examples: [
- [ "(Y|N)" ]
+ [ "(Y|N)" ],
],
},
{
present: String.raw`\\[Zz]`,
text: "The ECMAScript (JavaScript) specification does not support \\Z or \\z.",
examples: [
- [ "^Y|N\\z" ]
+ [ "^Y|N\\z" ],
],
},
{
absent: String.raw`\$$`,
text: "For input validation, end with '$' to indicate a full match.",
examples: [
- [ "^(Y|N)" ]
+ [ "^(Y|N)" ],
],
},
{
absent: String.raw`[\|\[]`,
text: "Consider using [YN], to match either a Y or an N.",
examples: [
- [ "^$" ]
+ [ "^$" ],
],
},
{
@@ -48,14 +48,14 @@ info =
absent: String.raw`\(`,
text: "If you use \"|\" you must parentheses or the precedence will be wrong. For example, \"^A|B$\" accepts anything beginning with A, and it also accepts anything ending with B. That is not what you want.",
examples: [
- [ "^Y|N$" ]
+ [ "^Y|N$" ],
],
},
{
present: " ",
text: "Spaces normally match spaces in a regex. Do not use them in this case, because a space is not one of the allowed characters.",
examples: [
- [ "^[YN] $" ]
+ [ "^[YN] $" ],
],
},
{
@@ -63,7 +63,7 @@ info =
index: 1,
text: "For input validation, start with '^' to indicate a full match.",
examples: [
- [ "^[YN]$", "" ]
+ [ null, "" ],
],
},
{
@@ -71,7 +71,7 @@ info =
index: 1,
text: "For input validation, end with '$' to indicate a full match.",
examples: [
- [ "^[YN]$", "^" ]
+ [ null, "^" ],
],
},
{
@@ -79,87 +79,110 @@ info =
index: 1,
text: "You can use [A-Z] to match one uppercase Latin letter (A through Z).",
examples: [
- [ "^[YN]$", "^$" ]
+ [ null, "^$" ],
],
},
{
present: String.raw`\^\[A-Z\]\*`,
index: 1,
- text: "A \"*\" matches one or more, not one or more."
+ text: "A \"*\" matches one or more, not one or more.",
+ examples: [
+ [ null, "^[A-Z]*$" ],
+ ],
},
{
present: String.raw`\(`,
index: 1,
- text: "You do not need parentheses to solve this problem."
+ text: "You do not need parentheses to solve this problem.",
+ examples: [
+ [ null, "^([A-Z])+$" ],
+ ],
},
{
- absent: String.raw`(\[A-Z\]\+|
- \[A-Z\]\[A-Z\]\*)`,
+ absent: String.raw`\[A-Z\](\+|\[A-Z\]\*)`,
index: 1,
text: "You can use [A-Z]+ to match one or more uppercase Latin letters.",
examples: [
- [ "^[YN]$", "^[A-Z]$" ]
+ [ null, "^[A-Z]$" ],
],
},
{
present: "True",
index: 2,
- text: "Regular expressions are case-sensitive by default; use \"true\"."
+ text: "Regular expressions are case-sensitive by default; use \"true\"",
+ examples: [
+ [ null, null, "True" ],
+ ],
},
{
present: "False",
index: 2,
- text: "Regular expressions are case-sensitive by default; use \"false\"."
+ text: "Regular expressions are case-sensitive by default; use \"false\".",
+ examples: [
+ [ null, null, "False" ],
+ ],
},
{
absent: String.raw`\|`,
index: 2,
- text: "Use \"|\" to express alternatives."
+ text: "Use \"|\" to express alternatives.",
},
{
present: String.raw`^\^true\|false\$$`,
index: 2,
- text: "No. This would match anything beginning with the term true, or anything ending with the term false. Use parenthesis."
+ text: "No. This would match anything beginning with the term true, or anything ending with the term false. Use parenthesis.",
},
{
present: String.raw`^\^false\|true\$$`,
index: 2,
- text: "No. This would match anything beginning with the term false, or anything ending with the term true. Use parenthesis."
+ text: "No. This would match anything beginning with the term false, or anything ending with the term true. Use parenthesis.",
},
{
absent: String.raw`\(`,
index: 2,
- text: "Use parentheses."
+ text: "Use parentheses.",
},
{
present: String.raw`\$`,
index: 3,
- text: "This is Python, not ECMAScript (JavaScript). Use \\Z at the end, not $."
+ text: "This is Python, not ECMAScript (JavaScript). Use \\Z at the end, not $.",
+ examples: [
+ [ null, null, null, "^[A-Z]+$"],
+ ],
},
{
present: String.raw`\\z`,
index: 3,
- text: "This is Python. Use \\Z at the end, not \\z."
+ text: "This is Python. Use \\Z at the end, not \\z.",
+ examples: [
+ [ null, null, null, "^[A-Z]+\\z"],
+ ],
},
{
absent: String.raw`^\\A`,
index: 4,
- text: "This is Ruby. Use \\A at the beginning."
+ text: "This is Ruby. Use \\A at the beginning.",
+ examples: [
+ [ null, null, null, null, "^[A-Z]+$"],
+ ],
},
{
absent: String.raw`\\z$`,
index: 4,
- text: "This is Ruby. Use \\z at the end."
+ text: "This is Ruby. Use \\z at the end.",
+ examples: [
+ [ null, null, null, null, "\\A[A-Z]+$"],
+ ],
},
{
absent: String.raw`\[A-Z\]`,
index: 4,
- text: "Use [A-Z] to match one uppercase Latin letter."
+ text: "Use [A-Z] to match one uppercase Latin letter.",
},
{
present: String.raw`\[A-Z\](\*|\+)`,
index: 4,
- text: "In this case we are only matching one letter, not many of them. Do not use \"*\" or \"+\" after [A-Z]."
+ text: "In this case we are only matching one letter, not many of them. Do not use \"*\" or \"+\" after [A-Z].",
},
],
expected: [