質問編集履歴
5
ddddddddd
test
CHANGED
File without changes
|
test
CHANGED
@@ -141,3 +141,73 @@
|
|
141
141
|
```
|
142
142
|
|
143
143
|
^[a-z]+$のエラーが消えないのですが、どのように直したらいいのかわかりません。
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
```修正2
|
150
|
+
|
151
|
+
package pra01;
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
class main {
|
156
|
+
|
157
|
+
public static void main(String[] args) {
|
158
|
+
|
159
|
+
rep text01 = new rep();
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
System.out.println(text01.rep("abcdef"));
|
164
|
+
|
165
|
+
}
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
package pra01;
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
import java.util.regex.Matcher;
|
174
|
+
|
175
|
+
import java.util.regex.Pattern;
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
public class rep {
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
public Matcher rep(String str) {
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
//判定する文字列
|
188
|
+
|
189
|
+
String a = str;
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
//判定するパターンを生成
|
194
|
+
|
195
|
+
Pattern b = Pattern.compile("^[a-z]+$");
|
196
|
+
|
197
|
+
Matcher m = b.matcher(a);
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
return m;
|
202
|
+
|
203
|
+
}}
|
204
|
+
|
205
|
+
コンソール
|
206
|
+
|
207
|
+
java.util.regex.Matcher[pattern=^[a-z]+$ region=0,6 lastmatch=]
|
208
|
+
|
209
|
+
```
|
210
|
+
|
211
|
+
上記また修正いたしましたが、コンソールにjava.util.regex.Matcher[pattern=^[a-z]+$ region=0,6 lastmatch=]とでたのですが、
|
212
|
+
|
213
|
+
検索しても実行が正常にできているのかがわからないのですが、こちらは実行できているんでしょうか?
|
4
dddddddd
test
CHANGED
File without changes
|
test
CHANGED
@@ -110,9 +110,23 @@
|
|
110
110
|
|
111
111
|
public String rep(String str) {
|
112
112
|
|
113
|
+
|
114
|
+
|
115
|
+
String a = str;
|
116
|
+
|
117
|
+
String b = ^[a-z]+$;
|
113
118
|
|
114
119
|
|
120
|
+
|
121
|
+
if (a == b) {
|
122
|
+
|
115
|
-
Strin
|
123
|
+
System.out.println("等しいです");
|
124
|
+
|
125
|
+
} else {
|
126
|
+
|
127
|
+
System.out.println("等しくありません");
|
128
|
+
|
129
|
+
}
|
116
130
|
|
117
131
|
|
118
132
|
|
@@ -120,12 +134,10 @@
|
|
120
134
|
|
121
135
|
}}
|
122
136
|
|
123
|
-
|
124
|
-
|
125
|
-
|
137
|
+
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
|
126
138
|
|
127
139
|
トークン "^" に構文エラーがあります。Expression が無効です
|
128
140
|
|
129
141
|
```
|
130
142
|
|
131
|
-
|
143
|
+
^[a-z]+$のエラーが消えないのですが、どのように直したらいいのかわかりません。
|
3
ss
test
CHANGED
File without changes
|
test
CHANGED
@@ -53,3 +53,79 @@
|
|
53
53
|
}
|
54
54
|
|
55
55
|
```
|
56
|
+
|
57
|
+
```修正java
|
58
|
+
|
59
|
+
package pra01;
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
class main {
|
64
|
+
|
65
|
+
public static void main(String[] args) {
|
66
|
+
|
67
|
+
String text = "abcdef";
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
System.out.println(text.matches("^[a-z]+$"));
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
結果→ true //^[a-z]+$"結果を確認できた。
|
78
|
+
|
79
|
+
```
|
80
|
+
|
81
|
+
```修正java メソッドで確認
|
82
|
+
|
83
|
+
package pra01;
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
class main {
|
88
|
+
|
89
|
+
public static void main(String[] args) {
|
90
|
+
|
91
|
+
rep text01 = new rep();
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
System.out.println(text01.rep("abcdef"));
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
package pra01;
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
public class rep {
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
public String rep(String str) {
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
String rep02 =^[a-z]+$;
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
return null;
|
120
|
+
|
121
|
+
}}
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
→Exception in thread "main" java.lang.Error: Unresolved compilation problem:
|
126
|
+
|
127
|
+
トークン "^" に構文エラーがあります。Expression が無効です
|
128
|
+
|
129
|
+
```
|
130
|
+
|
131
|
+
上記のエラーは^[a-z]+$の公文エラーのことでしょうか?^を削除してもエラーが消えませんでした。
|
2
ff
test
CHANGED
File without changes
|
test
CHANGED
@@ -17,3 +17,39 @@
|
|
17
17
|
|
18
18
|
|
19
19
|
全角英小文字はどのような書き方になるのか教えて頂きたいです。
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
```Java
|
26
|
+
|
27
|
+
package pra01;
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
public class tes {
|
32
|
+
|
33
|
+
var rep =/^[a-z]+$/;
|
34
|
+
|
35
|
+
}
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
package pra01;
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
class main {
|
44
|
+
|
45
|
+
public static void main(String[] args) {
|
46
|
+
|
47
|
+
tes test01 = new tes();
|
48
|
+
|
49
|
+
System.out.println(test01.rep("ABcd"));
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
```
|
1
ss
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|