|
| 1 | +info2 = |
| 2 | +{ |
| 3 | + hints: [ |
| 4 | + { |
| 5 | + present: "/", |
| 6 | + 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).", |
| 7 | + "examples": [ |
| 8 | + [ "/" ] |
| 9 | + ] |
| 10 | + }, |
| 11 | + { |
| 12 | + present: "[\"'`]", |
| 13 | + text: "In this exercise we only want the regular expression pattern itself. There is no need to use any kind of quote mark.", |
| 14 | + "examples": [ |
| 15 | + [ "'" ] |
| 16 | + ] |
| 17 | + }, |
| 18 | + { |
| 19 | + absent: String.raw`^\^`, |
| 20 | + text: "For input validation, start with '^' to indicate a full match.", |
| 21 | + "examples": [ |
| 22 | + [ "(Y|N)" ] |
| 23 | + ] |
| 24 | + }, |
| 25 | + { |
| 26 | + present: String.raw`\\[Zz]`, |
| 27 | + text: "The ECMAScript (JavaScript) specification does not support \\Z or \\z.", |
| 28 | + "examples": [ |
| 29 | + [ "^Y|N\\z" ] |
| 30 | + ] |
| 31 | + }, |
| 32 | + { |
| 33 | + absent: String.raw`\$$`, |
| 34 | + text: "For input validation, end with '$' to indicate a full match.", |
| 35 | + "examples": [ |
| 36 | + [ "^(Y|N)" ] |
| 37 | + ] |
| 38 | + }, |
| 39 | + { |
| 40 | + absent: String.raw`[\|\[]`, |
| 41 | + text: "Consider using [YN], to match either a Y or an N.", |
| 42 | + "examples": [ |
| 43 | + [ "^$" ] |
| 44 | + ] |
| 45 | + }, |
| 46 | + { |
| 47 | + present: String.raw`\|`, |
| 48 | + absent: String.raw`\(`, |
| 49 | + 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.", |
| 50 | + "examples": [ |
| 51 | + [ "^Y|N$" ] |
| 52 | + ] |
| 53 | + }, |
| 54 | + { |
| 55 | + present: " ", |
| 56 | + 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.", |
| 57 | + "examples": [ |
| 58 | + [ "^[YN] $" ] |
| 59 | + ] |
| 60 | + }, |
| 61 | + { |
| 62 | + absent: String.raw`^\^`, |
| 63 | + "index": 1, |
| 64 | + text: "For input validation, start with '^' to indicate a full match.", |
| 65 | + "examples": [ |
| 66 | + [ "^[YN]$", "" ] |
| 67 | + ] |
| 68 | + }, |
| 69 | + { |
| 70 | + absent: String.raw`\$$`, |
| 71 | + "index": 1, |
| 72 | + text: "For input validation, end with '$' to indicate a full match.", |
| 73 | + "examples": [ |
| 74 | + [ "^[YN]$", "^" ] |
| 75 | + ] |
| 76 | + }, |
| 77 | + { |
| 78 | + absent: String.raw`\[A-Z\]`, |
| 79 | + "index": 1, |
| 80 | + text: "You can use [A-Z] to match one uppercase Latin letter (A through Z).", |
| 81 | + "examples": [ |
| 82 | + [ "^[YN]$", "^$" ] |
| 83 | + ] |
| 84 | + }, |
| 85 | + { |
| 86 | + present: String.raw`\^\[A-Z\]\*`, |
| 87 | + "index": 1, |
| 88 | + text: "A \"*\" matches one or more, not one or more." |
| 89 | + }, |
| 90 | + { |
| 91 | + present: String.raw`\(`, |
| 92 | + "index": 1, |
| 93 | + text: "You do not need parentheses to solve this problem." |
| 94 | + }, |
| 95 | + { |
| 96 | + absent: String.raw`(\[A-Z\]\+| |
| 97 | + \[A-Z\]\[A-Z\]\*)`, |
| 98 | + "index": 1, |
| 99 | + text: "You can use [A-Z]+ to match one or more uppercase Latin letters.", |
| 100 | + "examples": [ |
| 101 | + [ "^[YN]$", "^[A-Z]$" ] |
| 102 | + ] |
| 103 | + }, |
| 104 | + { |
| 105 | + present: "True", |
| 106 | + "index": 2, |
| 107 | + text: "Regular expressions are case-sensitive by default; use \"true\"." |
| 108 | + }, |
| 109 | + { |
| 110 | + present: "False", |
| 111 | + "index": 2, |
| 112 | + text: "Regular expressions are case-sensitive by default; use \"false\"." |
| 113 | + }, |
| 114 | + { |
| 115 | + absent: String.raw`\|`, |
| 116 | + "index": 2, |
| 117 | + text: "Use \"|\" to express alternatives." |
| 118 | + }, |
| 119 | + { |
| 120 | + present: String.raw`^\^true\|false\$$`, |
| 121 | + "index": 2, |
| 122 | + text: "No. This would match anything beginning with the term true, or anything ending with the term false. Use parenthesis." |
| 123 | + }, |
| 124 | + { |
| 125 | + present: String.raw`^\^false\|true\$$`, |
| 126 | + "index": 2, |
| 127 | + text: "No. This would match anything beginning with the term false, or anything ending with the term true. Use parenthesis." |
| 128 | + }, |
| 129 | + { |
| 130 | + absent: String.raw`\(`, |
| 131 | + "index": 2, |
| 132 | + text: "Use parentheses." |
| 133 | + }, |
| 134 | + { |
| 135 | + present: String.raw`\$`, |
| 136 | + "index": 3, |
| 137 | + text: "This is Python, not ECMAScript (JavaScript). Use \\Z at the end, not $." |
| 138 | + }, |
| 139 | + { |
| 140 | + present: String.raw`\\z`, |
| 141 | + "index": 3, |
| 142 | + text: "This is Python. Use \\Z at the end, not \\z." |
| 143 | + }, |
| 144 | + { |
| 145 | + absent: String.raw`^\\A`, |
| 146 | + "index": 4, |
| 147 | + text: "This is Ruby. Use \\A at the beginning." |
| 148 | + }, |
| 149 | + { |
| 150 | + absent: String.raw`\\z$`, |
| 151 | + "index": 4, |
| 152 | + text: "This is Ruby. Use \\z at the beginning." |
| 153 | + }, |
| 154 | + { |
| 155 | + absent: String.raw`\[A-Z\]`, |
| 156 | + "index": 4, |
| 157 | + text: "Use [A-Z] to match one uppercase Latin letter." |
| 158 | + }, |
| 159 | + { |
| 160 | + present: String.raw`\[A-Z\](\*|\+)`, |
| 161 | + "index": 4, |
| 162 | + text: "In this case we are only matching one letter, not many of them. Do not use \"*\" or \"+\" after [A-Z]." |
| 163 | + } |
| 164 | + ], |
| 165 | + preprocessing: [ |
| 166 | + [ |
| 167 | + "\\s*", |
| 168 | + "" |
| 169 | + ] |
| 170 | + ] |
| 171 | +} |
0 commit comments