質問編集履歴
2
プログラムの修正をしました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -5,8 +5,8 @@
|
|
5
5
|
String s2 = "b";
|
6
6
|
Pattern pattern = Pattern.compile(s1);
|
7
7
|
Pattern pattern2 = Pattern.compile(s2);
|
8
|
-
Matcher matcher =
|
8
|
+
Matcher matcher = pattern.matcher(S);
|
9
|
-
Matcher matcher2 =
|
9
|
+
Matcher matcher2 = pattern2.matcher(S);
|
10
10
|
|
11
11
|
System.out.println(matcher.find());
|
12
12
|
System.out.println(matcher2.find());
|
1
プログラムの修正をしました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
System.out.println(matcher.groupCount());
|
25
25
|
System.out.println(matcher2.groupCount());
|
26
26
|
```
|
27
|
-
のMatcher.
|
27
|
+
のMatcher.groupCount()の命令は0が返ってきます。
|
28
28
|
|
29
29
|
Matcher.find()の命令でtrueが返ってきているので、文字列Sの中の"a"や"b"のを拾ってくれていると思うのですが、
|
30
30
|
Matcher.groupCount()の答えが0になってしまう理由が分かりません。
|