|
15 | 15 | }, |
16 | 16 | { |
17 | 17 | present: "(islength|Islength|IsLength|ISLENGTH)", |
18 | | - text: "JavaScript is case-sensitive. Use isLength instead of the case you have.\n" |
| 18 | + text: "JavaScript is case-sensitive. Use isLength instead of the case you have." |
19 | 19 | }, |
20 | 20 | { |
21 | 21 | absent: "isLength", |
@@ -47,13 +47,30 @@ info = |
47 | 47 | }, |
48 | 48 | { |
49 | 49 | present: String.raw`matches \( /.*(\[0-9\]|\d)\*`, |
50 | | - text: "You need to match one or more digits; * allows 0 or more. A + would be better suited for this task.\n" |
| 50 | + text: "You need to match one or more digits; * allows 0 or more. A + would be better suited for this task." |
51 | 51 | }, |
52 | 52 | { |
53 | 53 | present: String.raw`\s*, , $`, |
54 | | - 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" |
| 54 | + 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." |
55 | 55 | } |
56 | 56 | ], |
| 57 | + expected: [ |
| 58 | + String.raw` query('id').isLength({max:80}). |
| 59 | + matches( /^[A-Z]{2}-[0-9]+-[0-9]+$/ ),`, |
| 60 | + ], |
| 61 | + // Full pattern of correct answer. |
| 62 | + // This specific example is a worst case; we're using |
| 63 | + // a regex to check on a regex, requiring a large number of escapes. |
| 64 | + correct: [ |
| 65 | + // This pattern is very generous, allowing |
| 66 | + // constructs like \d for digits and {1,} instead of +. |
| 67 | + String.raw`\s* |
| 68 | + query \( ('id'|"id"|${BACKQUOTE}id${BACKQUOTE}) \) |
| 69 | + \. isLength \( \{ max: 80 ,? \} \) |
| 70 | + \. matches \( |
| 71 | + \/\^\[A-Z\](\{2\}|\[A-Z\])-(\[0-9\]|\\d)(\+|\{1,\})-(\[0-9\]|\\d)(\+|\{1,\})\$\/ |
| 72 | + \) , \s*` |
| 73 | + ], |
57 | 74 | successes: [ |
58 | 75 | [ |
59 | 76 | "query(`id`).isLength( {max:80}).matches(/^[A-Z]{2}-\\d+-[0-9]+$/)," |
|
74 | 91 | ], |
75 | 92 | [ |
76 | 93 | "query(`id`).isLength( {max:80}).matches(/^[A-Z]{2}-\\d+-[0-9]+$/)" |
77 | | - ] |
78 | | - ] |
| 94 | + ], |
| 95 | + [ |
| 96 | + "query(`id`).isLength( {max:80}).matches(/^[A-Z]{2}- \\d+-[0-9]+$/)," |
| 97 | + ], |
| 98 | + ], |
79 | 99 | } |
0 commit comments