回答編集履歴
2
ちょうせい
answer
CHANGED
@@ -4,12 +4,15 @@
|
|
4
4
|
|
5
5
|
```PHP
|
6
6
|
$pattern="/\A([^,、]+|([^,]+,)+[^,]+)\z/u";
|
7
|
+
$str="リンゴ";//o
|
8
|
+
print preg_match($pattern,$str)?"o":"x";
|
9
|
+
$str="リンゴ,バナナ,ぶどう";//o
|
10
|
+
print preg_match($pattern,$str)?"o":"x";
|
7
11
|
$str="リンゴ、バナナ、ぶどう";//x
|
8
12
|
print preg_match($pattern,$str)?"o":"x";
|
9
13
|
$str="リンゴ,バナナ,ぶどう,";//x
|
10
14
|
print preg_match($pattern,$str)?"o":"x";
|
11
|
-
$str="リンゴ,バナナ
|
15
|
+
$str="リンゴ,,バナナ";//x
|
12
16
|
print preg_match($pattern,$str)?"o":"x";
|
13
|
-
|
17
|
+
|
14
|
-
print preg_match($pattern,$str)?"o":"x";
|
15
18
|
```
|
1
chousei
answer
CHANGED
@@ -1,1 +1,15 @@
|
|
1
|
-
「リンゴ、バナナ、ぶどう」がNGで「リンゴ」がOKは合理的ではありません
|
1
|
+
「リンゴ、バナナ、ぶどう」がNGで「リンゴ」がOKは合理的ではありません
|
2
|
+
|
3
|
+
# sample
|
4
|
+
|
5
|
+
```PHP
|
6
|
+
$pattern="/\A([^,、]+|([^,]+,)+[^,]+)\z/u";
|
7
|
+
$str="リンゴ、バナナ、ぶどう";//x
|
8
|
+
print preg_match($pattern,$str)?"o":"x";
|
9
|
+
$str="リンゴ,バナナ,ぶどう,";//x
|
10
|
+
print preg_match($pattern,$str)?"o":"x";
|
11
|
+
$str="リンゴ,バナナ,ぶどう";//o
|
12
|
+
print preg_match($pattern,$str)?"o":"x";
|
13
|
+
$str="リンゴ";//o
|
14
|
+
print preg_match($pattern,$str)?"o":"x";
|
15
|
+
```
|