Skip to content

Commit 71f952b

Browse files
Merge pull request #871 from Muuhh-CTJ/jp-translation-regex0
Japanese translation of regex0
2 parents 3d932d8 + e675517 commit 71f952b

File tree

2 files changed

+117
-0
lines changed

2 files changed

+117
-0
lines changed

docs/labs/ja_regex0.html

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<!DOCTYPE html>
2+
<html lang="ja">
3+
<head>
4+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
7+
<link rel="stylesheet" href="checker.css">
8+
<script src="checker.js"></script>
9+
<script src="regex0.js"></script>
10+
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
11+
12+
<!-- See create_labs.md for how to create your own lab! -->
13+
14+
</head>
15+
<body>
16+
<!-- For GitHub Pages formatting: -->
17+
<div class="container-lg px-3 my-5 markdown-body">
18+
<h1>ラボ演習 regex0</h1>
19+
<p>
20+
これはセキュアなソフトウェア開発に関するラボ演習です。
21+
ラボの詳細については、<a href="introduction.html" target="_blank">概要</a>をご覧ください。
22+
23+
<p>
24+
<h2>ゴール</h2>
25+
<p>
26+
<b>
27+
シンプルな正規表現の書き方を学びます。
28+
</b>
29+
30+
<p>
31+
<h2>背景</h2>
32+
<p>
33+
正規表現(regular expressions: regexes)はテキストのパターンを表現するために広く利用されている表記方法です。
34+
ここでは入力検証のための正規表現の使い方を見ていきます。
35+
36+
<p>
37+
正規表現の表記方法は言語により若干異なりますが、大枠では共通しています。以下が正規表現を表記するための基本的なルールです。
38+
39+
<ol>
40+
<li>最も単純なルールは、文字や数字はそれ自身にマッチするということです。つまり、"<tt>d</tt>" という正規表現は "<tt>d</tt>" という文字にマッチします。多くの実装ではデフォルトで大文字・小文字を区別してマッチし、それは通常望まれる動作です。
41+
<li>もうひとつのルールは、いくつかの文字のうちどれかを指定するために角カッコで囲むというものです。もし角カッコが単なる英数字を囲っていた場合は、それらは囲まれた英数字のどれかにマッチします。つまり <tt>[brt]</tt> は単一の文字である "<tt>b</tt>", "<tt>r</tt>", "<tt>t</tt>" のどれかにマッチします。
42+
カッコの中ではダッシュ("-")で文字の範囲を示すことができます。つまり <tt>[A-D]</tt> はその範囲の一文字、すなわち一文字の A、一文字の B、一文字の C、一文字の D のどれかにマッチします。
43+
カッコの中には複数の範囲を書くことができます。
44+
例えば <tt>[A-Za-z]</tt> は、大文字のアルファベット一文字または小文字のアルファベット一文字にマッチします。
45+
(このラボでは EBCDIC のような使われなくなって久しい文字システムを使用していないと仮定しています)
46+
<li>パターンに続けて "<tt>&#42;</tt>" が書かれた場合、それは"<i>0回以上</i>"を意味します。
47+
ほとんど全ての正規表現の実装では(ただし POSIX BRE を除く)、パターンに続けて "<tt>+</tt>" が書かれた場合は"<i>1回以上</i>"を意味します。
48+
つまり <tt>[A-D]*</tt> は、A, B, C, D のどれかが0文字以上続く場合にマッチします。
49+
</ol>
50+
51+
<p>
52+
<h2>タスクの詳細</h2>
53+
<p>
54+
特定のパターンを検索するためのシンプルな正規表現(regular expression: regexes)を書いてみましょう。
55+
必要に応じて「ヒント」や「諦める」のボタンを押してください。
56+
57+
<p>
58+
<h2>演習 (<span id="grade"></span>)</h2>
59+
60+
<b>
61+
以下の要求を満たす正規表現(regex)のパターンを作成してください。
62+
</b>
63+
64+
<h3>Part 1</h2>
65+
<p>
66+
ECMAScript (JavaScript) で使うことを想定して、"cat" という語句が文のどこにあるかに関わらず検索するための正規表現を作成してください。
67+
<!--
68+
You can use this an example for new labs.
69+
For multi-line inputs, instead of <input id="attempt0" type="text" ...>, use
70+
<textarea id="attempt" rows="2" cols="65">...</textarea>
71+
-->
72+
<form id="lab1"><pre><code
73+
><input id="attempt0" type="text" size="60" spellcheck="false" value="">
74+
</code></pre>
75+
<button type="button" class="hintButton">ヒント</button>
76+
<button type="button" class="resetButton">リセット</button>
77+
<button type="button" class="giveUpButton">諦める</button>
78+
</form>
79+
80+
<h3>Part 2</h2>
81+
<p>
82+
ECMAScript (JavaScript) で使うことを想定して、1つ以上の "A" と1つ以上の "B" が連続する箇所を検索するための正規表現を作成してください。
83+
<!--
84+
You can use this an example for new labs.
85+
For multi-line inputs, instead of <input id="attempt0" type="text" ...>, use
86+
<textarea id="attempt" rows="2" cols="65">...</textarea>
87+
-->
88+
<form id="lab2">
89+
<pre><code
90+
><input id="attempt1" type="text" size="60" spellcheck="false" value="">
91+
</code></pre>
92+
<button type="button" class="hintButton">ヒント</button>
93+
<button type="button" class="resetButton">リセット</button>
94+
<button type="button" class="giveUpButton">諦める</button>
95+
</form>
96+
97+
<br><br>
98+
<p>
99+
<i>このラボは、<a href="https://www.linuxfoundation.org/">Linux Foundation</a>のDavid A. Wheelerによって開発されました。</i>
100+
<br><br>
101+
<p id="correctStamp" class="small">
102+
<textarea id="debugData" class="displayNone" rows="20" cols="65" readonly>
103+
</textarea>
104+
105+
</div><!-- End GitHub pages formatting -->
106+
</body>
107+
</html>

docs/labs/regex0.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,39 @@ info =
99
{
1010
present: "^$",
1111
text: "You need to enter a pattern.",
12+
text_ja: "パターンを入力してください。",
1213
examples: [
1314
[ "" ]
1415
],
1516
},
1617
{
1718
present: String.raw`^\^`,
1819
text: "We are looking for 'cat' anywhere, not just the beginning, in this exercise.",
20+
text_ja: "文の先頭だけではなく、どこに 'cat' があっても検索できるようにしましょう。",
1921
examples: [
2022
[ "^cat" ],
2123
],
2224
},
2325
{
2426
present: "C",
2527
text: "Regexes are normally case-sensitive. Use a lowercase c.",
28+
text_ja: "正規表現は通常大文字と小文字を区別します。ここでは小文字の c を使いましょう。",
2629
examples: [
2730
[ "C" ],
2831
],
2932
},
3033
{
3134
absent: "c",
3235
text: "If you are searching for \"cat\" you need to look for a \"c\"",
36+
text_ja: "\"cat\" を検索するにはまず \"c\" を検索する必要があります。",
3337
examples: [
3438
[ "x" ],
3539
],
3640
},
3741
{
3842
present: String.raw`\[(cat|act)\]`,
3943
text: "The pattern '[cat]' or '[act]' matches one latter, a 'c', an 'a', or 't'. That is not what you want.",
44+
text_ja: "'[cat]' や '[act]' は一文字の 'c'、一文字の 'a'、または一文字の 't' にマッチします。これは望ましい結果ではありません。",
4045
examples: [
4146
[ "[cat]" ],
4247
[ "[act]" ],
@@ -45,6 +50,7 @@ info =
4550
{
4651
absent: "cat",
4752
text: "The pattern \"cat\" is needed to search for \"cat\".",
53+
text_ja: "\"cat\" を検索するためにはパターンとして \"cat\" が必要です。",
4854
examples: [
4955
[ "c" ],
5056
],
@@ -53,6 +59,7 @@ info =
5359
absent: "A",
5460
index: 1,
5561
text: "You need to mention A.",
62+
text_ja: "A を忘れていませんか?",
5663
examples: [
5764
[ null, "B" ],
5865
],
@@ -61,6 +68,7 @@ info =
6168
absent: String.raw`A(\+|A\*)`,
6269
index: 1,
6370
text: "Use \"A+\" to indicate \"one or more A\". You could also write \"AA*\".",
71+
text_ja: "\"一つかそれ以上の A\" には \"A+\" を使用します。または \"AA*\" とも書けます。",
6472
examples: [
6573
[ null, "A" ],
6674
[ null, "AA" ],
@@ -70,6 +78,7 @@ info =
7078
absent: "B",
7179
index: 1,
7280
text: "You need to mention B.",
81+
text_ja: "B を忘れていませんか?",
7382
examples: [
7483
[ null, "A+" ],
7584
],
@@ -79,6 +88,7 @@ info =
7988
present: 'A',
8089
index: 1,
8190
text: "Use \"B+\" to indicate \"one or more B\". You could also write \"BB*\".",
91+
text_ja: "\"一つかそれ以上の B\" には \"B+\" を使用します。または \"BB*\" とも書けます。",
8292
examples: [
8393
[ null, "A+B" ],
8494
],

0 commit comments

Comments
 (0)