You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/labs/regex1.html
+12-4Lines changed: 12 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -297,10 +297,13 @@ <h2>Task Information</h2>
297
297
<p>
298
298
We want to use regexes to <i>validate</i> input.
299
299
That is, the input should <i>completely</i> match the regex pattern.
300
-
In regexes you can do this by prepending some symbol and appending a different
300
+
In regexes you can do this by using its default mode
301
+
(not a "multiline" mode), prepending some symbol, and appending a different
301
302
symbol.
302
-
Unfortunately, different languages use different symbols.
303
-
The following table shows what you should prepend and append.
303
+
Unfortunately, different platforms use different regex
304
+
symbols for performing a complete match to an input.
305
+
The following table shows what you should prepend and append for
306
+
many different platforms (for their default regex system).
304
307
305
308
<p>
306
309
<table>
@@ -331,7 +334,12 @@ <h2>Task Information</h2>
331
334
</table>
332
335
333
336
<p>
334
-
For example, to validate in JavaScript that the input is only “ab” or “de”, use the regex “^(ab|de)$”. To validate the same thing in Python, use “^(ab|de)\Z” or “\A(ab|de)\Z”.
337
+
For example, to validate in ECMAScript (JavaScript)
338
+
that an input is must be either “<tt>ab</tt>” or “<tt>de</tt>”,
339
+
use the regex “<tt>^(ab|de)$</tt>”.
340
+
To validate the same thing in Python, use
341
+
“<tt>^(ab|de)\Z</tt>” or “<tt>\A(ab|de)\Z</tt>” (note that it's
0 commit comments