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
78 changes: 0 additions & 78 deletions docs/labs/regex1.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,84 +12,6 @@

<!-- See create_labs.md for how to create your own lab! -->

<!-- Sample expected answer -->
<script id="expected0" type="plain/text">
^[YN]$
</script>

<!-- Full pattern of correct answer -->
<script id="correct0" type="plain/text">
\^(
\[YN\]|
\[NY\]|
\( (\?\:)? Y\|N \)|
\( (\?\:)? N\|Y \)
)\$
</script>

<!-- Sample expected answer -->
<script id="expected1" type="plain/text">
^[A-Z]+$
</script>

<!-- Full pattern of correct answer -->
<script id="correct1" type="plain/text">
\^
\[A-Z\]
(\+|\[A-Z\]\*)
\$
</script>

<!-- Sample expected answer -->
<script id="expected2" type="plain/text">
^(true|false)$
</script>

<!-- Full pattern of correct answer -->
<script id="correct2" type="plain/text">
\^\( (\?\:)?
(
true\|false|
false\|true
)\)\$
</script>

<!-- Sample expected answer -->
<script id="expected3" type="plain/text">
^[A-Z]+\Z
</script>

<!-- Full pattern of correct answer -->
<script id="correct3" type="plain/text">
\^
\[A-Z\]
(\+|\[A-Z\]\*)
\\Z
</script>

<!-- Sample expected answer.
Only matches one Latin letters (A through Z), followed by a
dash ("-"), followed by one or more digits.
This time, do it for Ruby (not JavaScript or Python).
-->
<script id="expected4" type="plain/text">
\A[A-Z]-[0-9]+\z
</script>

<!-- Full pattern of correct answer -->
<script id="correct4" type="plain/text">
\\A
\[A-Z\]
-
(\[0-9\]|\\d)
(\+|(\[0-9\]|\\d)\*)
\\z
</script>

<!--

-->

</head>
<body>
<!-- For GitHub Pages formatting: -->
Expand Down
21 changes: 21 additions & 0 deletions docs/labs/regex1.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,27 @@ info =
text: "In this case we are only matching one letter, not many of them. Do not use \"*\" or \"+\" after [A-Z]."
}
],
expected: [
'^[YN]$',
'^[A-Z]+$',
'^(true|false)$',
String.raw`^[A-Z]+\Z`,
String.raw`\A[A-Z]-[0-9]+\z`,
],
correct: [
String.raw`\^(
\[YN\]|\[NY\]|
\( (\?\:)? Y\|N \)|
\( (\?\:)? N\|Y \) )\$`,
String.raw`\^ \[A-Z\](\+|\[A-Z\]\*) \$`,
String.raw`\^\( (\?\:)?
(true\|false|false\|true)\)\$`,
// Python uses \Z
String.raw`\^ \[A-Z\] (\+|\[A-Z\]\*) \\Z`,
// Ruby uses \A and \z
String.raw`\\A \[A-Z\]-(\[0-9\]|\\d)
(\+|(\[0-9\]|\\d)\*) \\z`,
],
preprocessing: [
[
"\\s*",
Expand Down