回答編集履歴

2

ちょうせい

2021/06/29 05:58

投稿

yambejp
yambejp

スコア114883

test CHANGED
@@ -10,6 +10,14 @@
10
10
 
11
11
  $pattern="/\A([^,、]+|([^,]+,)+[^,]+)\z/u";
12
12
 
13
+ $str="リンゴ";//o
14
+
15
+ print preg_match($pattern,$str)?"o":"x";
16
+
17
+ $str="リンゴ,バナナ,ぶどう";//o
18
+
19
+ print preg_match($pattern,$str)?"o":"x";
20
+
13
21
  $str="リンゴ、バナナ、ぶどう";//x
14
22
 
15
23
  print preg_match($pattern,$str)?"o":"x";
@@ -18,12 +26,10 @@
18
26
 
19
27
  print preg_match($pattern,$str)?"o":"x";
20
28
 
21
- $str="リンゴ,バナナ,ぶどう";//o
29
+ $str="リンゴ,,バナナ";//x
22
30
 
23
31
  print preg_match($pattern,$str)?"o":"x";
24
32
 
25
- $str="リンゴ";//o
26
33
 
27
- print preg_match($pattern,$str)?"o":"x";
28
34
 
29
35
  ```

1

chousei

2021/06/29 05:58

投稿

yambejp
yambejp

スコア114883

test CHANGED
@@ -1 +1,29 @@
1
1
  「リンゴ、バナナ、ぶどう」がNGで「リンゴ」がOKは合理的ではありません
2
+
3
+
4
+
5
+ # sample
6
+
7
+
8
+
9
+ ```PHP
10
+
11
+ $pattern="/\A([^,、]+|([^,]+,)+[^,]+)\z/u";
12
+
13
+ $str="リンゴ、バナナ、ぶどう";//x
14
+
15
+ print preg_match($pattern,$str)?"o":"x";
16
+
17
+ $str="リンゴ,バナナ,ぶどう,";//x
18
+
19
+ print preg_match($pattern,$str)?"o":"x";
20
+
21
+ $str="リンゴ,バナナ,ぶどう";//o
22
+
23
+ print preg_match($pattern,$str)?"o":"x";
24
+
25
+ $str="リンゴ";//o
26
+
27
+ print preg_match($pattern,$str)?"o":"x";
28
+
29
+ ```