diff --git a/docs/labs/input2.html b/docs/labs/input2.html index 78a79a78..5b1a84c1 100644 --- a/docs/labs/input2.html +++ b/docs/labs/input2.html @@ -10,30 +10,6 @@ - - - - - - diff --git a/docs/labs/input2.js b/docs/labs/input2.js index f9f95f0a..70890835 100644 --- a/docs/labs/input2.js +++ b/docs/labs/input2.js @@ -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", @@ -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]+$/)," @@ -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]+$/)," + ], + ], }